Tutorial: Column Chooser API

  • 2 minutes to read

This walkthrough is a transcript of the Column Chooser API video available on the DevExpress YouTube Channel.

In this tutorial, you'll take a look at the API that works with the Column Chooser dialog.

Column Chooser API

Create a new action button in the Ribbon control, set its text to Show Column Chooser and write the Click hander for it. As you see, the dialog object is available using the GridView.CustomizationForm property. So, check if it has already been initialized, and depending on the result, show or hide the Column Chooser using the GridView.ShowCustomization or GridView.DestroyCustomization methods.


private void barButtonShowChooser_ItemClick(object sender, ItemClickEventArgs e) {
    if (gridView1.CustomizationForm == null)
        gridView1.ShowCustomization();
    else
        gridView1.DestroyCustomization();
}

To make sure that the button displays the correct label depending on the Column Chooser visibility, go to Grid View settings and first, find the GridView.ShowCustomizationForm event. It fires when the form becomes visible, so the handler should set the label to Hide Column Chooser. Similarly, in the GridView.HideCustomizationForm event, set the text back to Show Column Chooser.


private void gridView1_ShowCustomizationForm(object sender, EventArgs e) {
    barButtonShowChooser.Caption = "Hide Column Chooser";
}

private void gridView1_HideCustomizationForm(object sender, EventArgs e) {
    barButtonShowChooser.Caption = "Show Column Chooser";
}

Run the application and first try the button to see that it invokes the dialog and the button label changes. You can also invoke the Column Chooser using the menu and see how the text still changes.

See Also