Skip to content

Create a custom button and display it in the grid's data navigator.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/winforms-grid-data-navigator-custom-button

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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