【问题标题】:How do I place a picture on the form?如何在表格上放置图片?
【发布时间】:2018-04-19 04:45:22
【问题描述】:

关于 NWindLayout 演示的问题
dxdemo://Win/XtraGrid/MainDemo/NWindLayout

scrin1

scrin2

如何在字段中放置图像?
我需要将图片存储在数据库中吗?

图片存储在本地磁盘上,数据库存储图片的链接,“照片”字段根据链接显示照片?

【问题讨论】:

    标签: devexpress devexpress-windows-ui devexpress-gridcontrol


    【解决方案1】:

    据我了解,您的数据库中有一个列,其数据是表示图像路径的字符串。并且您将 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 示例,了解这种方法的实际应用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-21
      • 2012-03-10
      • 1970-01-01
      • 1970-01-01
      • 2011-07-09
      • 1970-01-01
      • 1970-01-01
      • 2022-11-14
      相关资源
      最近更新 更多