2

我在 C#.NET 中编程并在我的应用程序中使用 XtraGrid 控件。

我在我的项目中使用 MyXtraGrid(自定义控件)。

现在我需要覆盖EmbeddedNavigator_ButtonClick自定义按钮:

  1. 导出到 Excel
  2. 打印等

但我不使用覆盖方法EmbeddedNavigator_ButtonClick

4

1 回答 1

3

EmbeddedNavigator.CustomButtons属性提供对自定义按钮集合的访问。您可以将所有需要的按钮添加到此集合中。要覆盖嵌入式导航器按钮的行为或实现自定义按钮的反应,您应该处理NavigatorBase.ButtonClick事件。这是一些示例代码:

class MyGridControl : DevExpress.XtraGrid.GridControl {
    public MyGridControl() {
        EmbeddedNavigator.ButtonClick += EmbeddedNavigator_ButtonClick;
    }
    //...
    void EmbeddedNavigator_ButtonClick(object sender, NavigatorButtonClickEventArgs e) {
        if(e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Delete) {
            // ... your code is here
            e.Handled = true;  // disable the default processing
        }
        if(e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Custom) {
            // ... your code is here
            e.Handled = true;  // disable the default processing
        }
    }
}
于 2012-05-02T07:28:48.867 回答