DevExpress Grid,Bool行更改不会立即反映 [英] DevExpress Grid, Bool rows change not reflect immediatly
问题描述
void gridView1_CellValueChanged(object sender,DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
//button1.PerformClick();
if(e.Column.Name ==col1)
{
var x = gridView1.GetRowCellValue(e.RowHandler,col1);
gridView1.SetRowCellValue(e.RowHandler,col2,x);
}
}
我在DX网站和没有解决办法。我该怎么处理呢?
您可以使用 GridView.PostEditor 方法,将更改的值从编辑器传递到Grid的底层数据源。执行此操作的最佳位置是真实单元格编辑器的 EditValueChanged 事件。您可以如下处理此事件:
gridView1.PopulateColumns();
var checkEdit = gridView1.Columns [Value1]。RealColumnEdit as RepositoryItemCheckEdit;
checkEdit.EditValueChanged + = checkEdit_EditValueChanged;
// ...
void checkEdit_EditValueChanged(object sender,EventArgs e){
gridView1.PostEditor();
}
然后,您可以实现所有需要的依赖关系:
gridView1.CellValueChanged + = gridView1_CellValueChanged;
// ...
void gridView1_CellValueChanged(object sender,DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e){
if(e.Column.FieldName ==Value1)
gridView1.SetRowCellValue(e.RowHandle,gridView1.Columns [Value2],e.Value);
}
I have a DX grid view and it has 2 bool columns. My purpose is when I check for ex 2nd row in column1, column2 2nd must be changed immediatly, but not. It changes after clicking another row. Here is my rowcellvaluechanged event code :
void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
//button1.PerformClick();
if (e.Column.Name == "col1")
{
var x = gridView1.GetRowCellValue(e.RowHandler, col1);
gridView1.SetRowCellValue(e.RowHandler, col2, x);
}
}
I looked for in DX website and there is no solution. How can I handle on it ?
You can use the GridView.PostEditor method to immediately pass the changed value from the editor into the Grid's underlying data source. The best place for doing this is the EditValueChanged event of real cell editor. You can handle this event as follows:
gridView1.PopulateColumns();
var checkEdit = gridView1.Columns["Value1"].RealColumnEdit as RepositoryItemCheckEdit;
checkEdit.EditValueChanged += checkEdit_EditValueChanged;
//...
void checkEdit_EditValueChanged(object sender, EventArgs e) {
gridView1.PostEditor();
}
Then you can implement all needed dependencies:
gridView1.CellValueChanged += gridView1_CellValueChanged;
//...
void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) {
if(e.Column.FieldName == "Value1")
gridView1.SetRowCellValue(e.RowHandle, gridView1.Columns["Value2"], e.Value);
}
这篇关于DevExpress Grid,Bool行更改不会立即反映的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!