wpf - wpf中DevExpress的DataGrid控件checkbox列的Checked事件

标签 wpf devexpress

我想在 wpf 中的 DevExpress 的 DataGrid 控件的复选框列的 Checked 事件上执行一些任务。

最佳答案

要跟踪相应 bool 列的值何时更改,我建议您处理 TabbedView.CellValueChanged事件:

((TableView)gridControl.View).CellValueChanged += MainWindow_CellValueChanged
//...
void MainWindow_CellValueChanged(object sender, CellValueChangedEventArgs e) {
    if(e.Column.FieldName == "BooleanProp") { 
        // do something
    }
}

要直接在单元格编辑器上跟踪选中/未选中事件,您可以使用以下方法:

((TableView)gridControl.View).ShownEditor += TableView_ShownEditor;
((TableView)gridControl.View).HiddenEditor += TableView_HiddenEditor;
//...

void TableView_ShownEditor(object sender, EditorEventArgs e) {
    if(e.Column.FieldName == "BooleanProp") {
        ((DevExpress.Xpf.Editors.CheckEdit)e.Editor).Checked += BooleanPropCheckEdit_Checked;
        ((DevExpress.Xpf.Editors.CheckEdit)e.Editor).Unchecked += BooleanPropCheckEdit_Unchecked;
    }
}
void TableView_HiddenEditor(object sender, EditorEventArgs e) {
    if(e.Column.FieldName == "BooleanProp") {
        ((DevExpress.Xpf.Editors.CheckEdit)e.Editor).Checked -= BooleanPropCheckEdit_Checked;
        ((DevExpress.Xpf.Editors.CheckEdit)e.Editor).Unchecked -= BooleanPropCheckEdit_Unchecked;
    }
}
void BooleanPropCheckEdit_Checked(object sender, RoutedEventArgs e) {
    // do something
}
void BooleanPropCheckEdit_Unchecked(object sender, RoutedEventArgs e) {
    // do something
}

关于wpf - wpf中DevExpress的DataGrid控件checkbox列的Checked事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17809435/

相关文章:

.net - 菜单项触发器不工作

WPF:如何 Hook 到 ListView 的 ItemsSource CollectionChanged 通知?

c# - 更改 deleteCommand 按钮文本

c# - 如何捕捉扩展器标题点击事件

c# - 停止方法并等待用户输入

c# - 不同类型列的过滤器表达式

c# - 如何在 XtraGridControl Devexpress 上设置焦点行?

c# - 在 xaml 中将 DockLayoutManager 与 View 模型文件绑定(bind)

c# - 发布版本中 visual studio 2010 中的核心转储

c# - 倾斜动画无法制作动画