如何使用dll中的图像
我有一个自定义的网格视图。 它有一个属性“主题”。 这个属性有一些项目(枚举)可以改变我的gridview的apperacne,例如hedar背景图像,rowstyle,rowcolor等...。 此属性工作正常。但我必须添加一个文件夹(包含图像)来显示标题的背景图像。 我必须为用户(在他们的网站中使用我的 gridview)准备这个文件夹。 我希望用户(程序员)添加我的 dll(gridview)并更改网格的主题,而无需任何额外的工作。 如果您在我的代码中看到我必须通过网站中的 floder 添加背景图像样式引用(ThemeResource/HeaderSoftGamer.png)。自然用户(程序员)必须复制使用我的 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;
}
}
}
}}
谢谢大家
i have a customized grid view.
it has a property "Theme".
this property has some item (enum) that change apperacne of my gridview such as hedar background image,rowstyle,rowcolor,etc... .
this property work fine.but i must add a folder (contained image) to show background image of header.
i must prepare this folder for users (that use my gridview in their website) .
i want just users(programmers) add my dll(gridview) and change theme of my grid without any additional work.
if you see in my code i must add backgroundimage style refrencde by a floder in web site(ThemeResource/HeaderSoftGamer.png).and naturally users(programmers) must copy this folder of page that use my 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;
}
}
}
}}
thank all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将图像保留在服务器上并从代码中使用它们,也可以提供完整的图像文件夹并要求他们将其包含在他们的项目中。我没有看到解决方法。
You can either keep your images on your server and use them from your code or give the complete image folder and ask them to include it with their project. I don't see a workaround for this..