代码之家  ›  专栏  ›  技术社区  ›  climivin

如何在表单上放置图片?

  •  0
  • climivin  · 技术社区  · 7 年前

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

    scrin1

    scrin2

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

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

    1 回复  |  直到 7 年前
        1
  •  0
  •   DmitryG    7 年前

    据我所知,数据库中有一列,其数据是表示图像路径的字符串。您正在将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 示例以查看此方法的实际应用。

    推荐文章