Skip to content

Latest commit

 

History

History
50 lines (39 loc) · 3.02 KB

File metadata and controls

50 lines (39 loc) · 3.02 KB

WinForms Data Grid - Create a custom button for the embedded navigator

This example demonstrates how to create a custom button and display it in the grid's data navigator.

private void Form1_Load(object sender, EventArgs e) {
    // ...
    gridControl1.UseEmbeddedNavigator = true;
    gridControl1.EmbeddedNavigator.ButtonClick += new DevExpress.XtraEditors.NavigatorButtonClickEventHandler(gridControl1_EmbeddedNavigator_ButtonClick);
    gridControl1.EmbeddedNavigator.Buttons.ImageList = imageCollection1;
    DevExpress.XtraEditors.NavigatorCustomButton button = gridControl1.EmbeddedNavigator.Buttons.CustomButtons.Add();
    button.Tag = "copy";
    button.Hint = "Copy to clipboard";
    button.ImageIndex = 0;
}
private void gridControl1_EmbeddedNavigator_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e) {
    if("copy".Equals(e.Button.Tag)) {
        if(gridControl1.FocusedView != null) {
            gridControl1.FocusedView.CopyToClipboard();
            MessageBox.Show("Selected data has been copied to the Clipboard");
            e.Handled = true;
        }
    }
}

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)