DevExpress:如何在gridView中通过索引获取值?
DevExpress: How to get value by index in gridView?
我有一个 GridWiew,数据库中的列 Status Id
和 table Status
列 Status Id
和 Value
。
在 GridView 中,我需要将状态编号替换为 table 中的值。
如何使用 GridView Designer 来实现?我想,应该有一些 属性 比如 binding source:
作为解决方案,您可以使用BaseView.GetRow method. This method will return an object that represents your data source item. To get the item's data source index, use the ColumnView.GetDataSourceRowIndex方法。
//It is just an example..
int dataSourceRowIndex = view.GetDataSourceRowIndex(gridView.FoucsedRowHandle);
//Let suppose you bind with datatable
dataTable.Rows[dataSourceRowIndex]["Status"]=editedValue;
您可以使用 FocusedRowHandle property to find the edited row. Also, you can use the CellValueChanged 事件及其 e.RowHandle
参数。
要更新数据库中的值,请使用 Post Data to an Underlying Data Source 文章中描述的方法之一,具体取决于数据源的类型。
参考文献:
How to get an item's data source row index of the sorted grid view
Update only some details row if master row is selected
我有一个 GridWiew,数据库中的列 Status Id
和 table Status
列 Status Id
和 Value
。
在 GridView 中,我需要将状态编号替换为 table 中的值。
如何使用 GridView Designer 来实现?我想,应该有一些 属性 比如 binding source:
作为解决方案,您可以使用BaseView.GetRow method. This method will return an object that represents your data source item. To get the item's data source index, use the ColumnView.GetDataSourceRowIndex方法。
//It is just an example..
int dataSourceRowIndex = view.GetDataSourceRowIndex(gridView.FoucsedRowHandle);
//Let suppose you bind with datatable
dataTable.Rows[dataSourceRowIndex]["Status"]=editedValue;
您可以使用 FocusedRowHandle property to find the edited row. Also, you can use the CellValueChanged 事件及其 e.RowHandle
参数。
要更新数据库中的值,请使用 Post Data to an Underlying Data Source 文章中描述的方法之一,具体取决于数据源的类型。
参考文献:
How to get an item's data source row index of the sorted grid view
Update only some details row if master row is selected