Infragistics的web control的确很强,现在我总结几条在cell中显示Image的小方法:
1.如果绑定grid至少一条记录的:
可以设置CellStyle中的Background 属性为图片的地址,也可以设置CustomRules 属性,使图片只显示一张(默认情况下是图片重复显示,直到添满cell)。在UltraWebGrid的InitializeRow 事件中添加下列代码片断即可实现。另外,如果需要图片有提示信息,可以设置该列的Title属性为要显示的文字。
e.Row.Cells.FromKey("ImageCol").Style.CustomRules = "Background-repeat:no-repeat"
e.Row.Cells.FromKey("ImageCol").Style.BackgroundImage = "images/landscape.jpg"
2.直接动态插入列
同样是在InitializeRow 事件中插入
e.Row.Cells.FromKey("ImageCol").Text = "<a href='http://somewebsite.com/downloads/default.aspx'><img src='../../Images/edit.gif'></a>"
同理,如果图片是Stream的,那么可以象这种方法一样,引向一下专门处理图片显示的空白页面。
1.如果绑定grid至少一条记录的:
可以设置CellStyle中的Background 属性为图片的地址,也可以设置CustomRules 属性,使图片只显示一张(默认情况下是图片重复显示,直到添满cell)。在UltraWebGrid的InitializeRow 事件中添加下列代码片断即可实现。另外,如果需要图片有提示信息,可以设置该列的Title属性为要显示的文字。
e.Row.Cells.FromKey("ImageCol").Style.CustomRules = "Background-repeat:no-repeat"
e.Row.Cells.FromKey("ImageCol").Style.BackgroundImage = "images/landscape.jpg"
同样是在InitializeRow 事件中插入
e.Row.Cells.FromKey("ImageCol").Text = "<a href='http://somewebsite.com/downloads/default.aspx'><img src='../../Images/edit.gif'></a>"
浙公网安备 33010602011771号