小编Gag*_*gan的帖子

如何在不使用cutomunboundcolumn事件的情况下从图像路径在gridview单元格中显示图像?

我有一个网格视图,我想在其中显示其路径存储在数据库中的图像.我试过这段代码,但它只重复所有行中的一张图片.任何人都可以帮我解决这个问题吗?我不想使用customunboundcolumn事件.我的代码如下所示

 SqlCommand cmd = new SqlCommand("select * from picture", con);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        adp.Fill(ds);
        gridControl1.DataSource = ds.Tables[0];
        DevExpress.XtraGrid.Columns.GridColumn image = new DevExpress.XtraGrid.Columns.GridColumn();
        gridView1.Columns.Add(image);
        image.Caption = "Image";
        image.Name = "img";
        image.FieldName = "img";
        image.Visible = true;
        image.VisibleIndex = 3;
        int row = ds.Tables[0].Rows.Count;
        DevExpress.XtraGrid.Views.Base.ColumnView cgv = (DevExpress.XtraGrid.Views.Base.ColumnView)gridView1;
        DevExpress.XtraEditors.Repository.RepositoryItemImageEdit rpic = new DevExpress.XtraEditors.Repository.RepositoryItemImageEdit();
        rpic.NullText = "No Image";
        rpic.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;
        DevExpress.Utils.ImageCollection images = new DevExpress.Utils.ImageCollection();
        for (int i = 0; i < row; i++)
        { …
Run Code Online (Sandbox Code Playgroud)

.net devexpress winforms gridcontrol

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net ×1

devexpress ×1

gridcontrol ×1

winforms ×1