GridControl 隐藏Drag a column header here to group by that column 添加或者删除行 禁止编辑 某一列的单元格显示图片

https://www.devexpress.com/Support/Center/Question/Details/Q412390

I have created a Grid Control to view the Currency table. As there are only ten records in the table, can I hide the "Drag a column header here to group by that column" bar for the Grid Control.

To achieve this goal disable the GridView.OptionsView.ShowGroupPanel option.

添加或者删除行

https://documentation.devexpress.com/#WindowsForms/CustomDocument752

 https://www.devexpress.com/Support/Center/Question/Details/T195251

Please accept my apologies for providing the incorrect information.

The grid can't operate without a data source.

However, you're able to create an empty DataTable (without rows) that has only columns.

Look at the following code:

DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Name", typeof(string));
gridControl1.DataSource = dt;

需要注意的是,手动添加了GridColumn的话,需要指定FiledName属性,要和DataTable中的列名保持一致。

设置时间格式,

https://www.devexpress.com/Support/Center/Question/Details/Q360794

To accomplish this task, set the GridColumn.DisplayFormat.FormatType property to the FormatType.DateTime value 

禁止编辑

gridView1.OptionsBehavior.Editable = false;

某一列的单元格显示图片

 设置GridColumn的ColumnEdit为PictureEdit,设置UnboundType为Object

GridControl
隐藏Drag a column header here to group by that column
添加或者删除行
禁止编辑
某一列的单元格显示图片

private DevExpress.XtraEditors.Repository.RepositoryItemPictureEdit repositoryItemPictureEdit1;

设置repositoryItemPictureEdit1的图片显示

GridControl
隐藏Drag a column header here to group by that column
添加或者删除行
禁止编辑
某一列的单元格显示图片

某一个单元格的单击事件

https://www.devexpress.com/Support/Center/Question/Details/Q406257

To accomplish this task, use the GridView.RowCellClick event.

Please note that this event will not fire when clicking on a row cell, if data editing is enabled and the ColumnViewOptionsBehavior.EditorShowMode property is set to MouseDown (and to Default, if multiple row selection is disabled). To accomplish this task, set the GridView.OptionsBehavior.EditorShowMode property to the EditorShowMode.MouseUp value.

 private void gridView1_RowCellClick(object sender, RowCellClickEventArgs e)
        {
            if (e.Column == gridColumn3)
            {
                //需要弹出对应行的场景配置详情
                Console.WriteLine($@"第{e.RowHandle + 1},第{e.Column.ColumnHandle}列");
            }
        }