关于NWindLayout演示的问题
dxdemo://赢/ XtraGrid中/ MainDemo / NWindLayout
如何在现场放置图像?
我是否需要将图片存储在数据库中?
或
图片存储在本地磁盘上,数据库存储图片链接,“照片”字段根据链接显示照片?
答案 0 :(得分:0)
据我所知,您的数据库中有一列,其数据是表示图像路径的字符串。并且您将PictureEdit指定为列的就地编辑器。如果是这样,建议使用未绑定列的方法,因为PictureEdit编辑器不提供通过将字符串路径设置为编辑器值来显示图像的功能:
void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) {
GridView view = sender as GridView;
if(e.Column.FieldName == "Image" && e.IsGetData) {
string fileName = view.GetRowCellValue(view.GetRowHandle(e.ListSourceRowIndex), "ImagePath");
e.Value = /* get image from cache by filename or load image from file and add to cache */
}
}
查看How to display external images in Grid if its data source contains links to the images示例,了解这种方法的实际效果。