背景
需要在gridview中增加一列。之前的数据都是通过Datatable 绑定到GridControl.DataSource呈现。(GridControl 不能只通过非绑定列呈现)
Note that the Grid Control cannot operate with only unbound columns (without binding the control to a data source using the GridControl.DataSource and GridControl.DataMember properties)。
问题描述
在gridview中通道Columns.AddField()添加了一列(GridColumn),当对这一列的单元格进行赋值时无效果。
赋值方式是通过gridView1.SetRowCellValue();
解决方法
响应gridView的CustomUnboundColumnData 消息,其中CustomColumnDataEventArgs 包含以下属性 IsSetData,IsGetData,Value等。
此消息在gridview初始化,以及其它绑定列的数据被修改时被激活,此时IsGetData为true,IsSetData为false;
对非绑定列的单元格进行编辑(添加非绑定列以后默认是可编辑的)和对非绑定列进行SetRowCellValue()时消息也被激