如何使用dll中的图像

时间:2010-12-14 09:26:40

标签: c# .net embedded-resource

我有一个自定义的网格视图。 它有一个属性“主题”。 这个属性有一些项目(枚举)改变我的gridview的apperacne,如hedar背景图像,rowstyle,rowcolor等.... 这个属性工作正常。但我必须添加一个文件夹(包含图像)来显示标题的背景图像。 我必须为用户准备这个文件夹(在他们的网站上使用我的gridview)。 我希望只是用户(程序员)添加我的DLL(gridview)并更改我的网格主题,而无需任何额外的工作。 如果你在我的代码中看到我必须通过网站(ThemeResource / HeaderSoftGamer.png)中的floder添加backgroundimage样式refrencde。自然用户(程序员)必须复制使用我的gridview的页面文件夹

 public class MTGridView : GridView
{
    public enum ThemeCollection { HardBlue, Black, Girly , Sky , Samta };
    private ThemeCollection currentTheme;
    public ThemeCollection Theme
    {
        get
        {
            return currentTheme;
        }
        set
        {
            currentTheme = value;
        }

    }
     public MTGridView()
    {
          this.RowCreated += new GridViewRowEventHandler(MTGridView_RowCreated);
    }
     void MTGridView_RowCreated(object sender, GridViewRowEventArgs e)
    {

        switch (Theme)
        {
            case ThemeCollection.Sky:
                {

                    switch (e.Row.RowType)
                    {
                        case DataControlRowType.Header:
                            e.Row.Style.Add("background-color", "blue");
                            e.Row.Style.Add("font-family", "Tahoma");
                            e.Row.Style.Add("font-size", hs.ToString());
                            e.Row.Style.Add("color", "Black");
                            e.Row.Style.Add("background-image", "url(ThemeResource/HeaderSoftGamer.png)");
                         break;
                     }
                   }
              }
     }}

谢天谢地

1 个答案:

答案 0 :(得分:0)

您可以将图像保存在服务器上并从代码中使用它们,也可以提供完整的图像文件夹,并要求它们将其包含在项目中。我没有看到解决方法..

相关问题