GridView Default Context Menu Customizing
In this article, we are going to talk about the way of customizing the default Kettic DataGridView context menu in the ContextMenuOpening event handler. To create the custom context menu, we need to initialize the items of custom context menus, and then subscribe for the events that you are going to handle to achieve desired behavior. The following examples will demonstrate how to remove and add context menus items to GridView C#.NET component for Windows Forms application.
Remove Context Menu Items from C#.NET GridView
The DataGridView control allows users easily remove an item from default KetticGridView context menu. To remove an item, we need to make a loop to iterate the e.ContextMenu.Items first, and then we need to check whether the e.ContextMenu.Items[].Text is equal to the text of the menu item that we are going to hide. If the conditions do like this, we can change the value of the Visibility of the menu item as Collapsed. The following are the C# code for deleting context menu items.
C# code for deleting context menu items from GridView C#.NET component in Windows Forms template project
Add Context Menu Items to C#.NET GridView
The DataGridView control allows users easily add menu items to the default Kettic DataGridView context menu. To add custom menu items to the default context menu in DataGridView control, we need to create menu item instances in the ContextMenuOpening event handler and add the instances to the e.ContextMenu.Items. The following are the C# code for adding custom context menu items.
C# code for adding custom context menu items to the default context menu in GridView for C# Windows Forms template project
|
UI Controlsfor Windows Forms .NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI DesignWinForms UI Controls WinForms Buttons UI Control WinForms Calendar UI ControlWinForms Carousel UI ControlWinForms Chart UI ControlWinForms Clock UI ControlCommandBar UI ControlWinForms Dock UI ControlDesktop Alert UI ControlDropDown List UI ControlWinForms Editor UI ControlForms and Dialogs UI ControlWinForms GridView UI ControlGridView - Get Started in C#GridView - PropertiesGridView - ColumnGridView - RowGridView - CellsGridView - EditorsGridView - Context MenuConditional Custom Context MenuModify Default Context MenuGridView - Populating with DataData BindingBinding to Array and ArrayListBinding to Generic ListBinding to Binding ListBinding to DataTable / DataSetBinding to DataReaderBinding to Sub ObjectsBinding to XMLUnbound ModeUpdate DatabaseGridView - Hierarchical GridGridView - SelectionGridView - ScrollingGridView - SortingGridView - GroupingGridView - FilteringGridView - Expression EditorInsert/ Update/ Delete RecordsGridView - View DefinitionGridView - Exporting DataStyling and AppearanceGridView - LocalizationSave and Load LayoutGridView - Print SupportWinForms ListView UI ControlWinForms Menu UI ControlWinForms ComboBox UI ControlWinForms PageView UI ControlPanels and Labels UI ControlWinForms Panorama UI ControlWinForms PDFViewer UI ControlWinForms Property Grid UI ControlWinForms Ribbon UI ControlWinForms PivotGrid UI ControlWinForms RichTextBox UI ControlWinForms Rotator UI ControlWinForms Scheduler UI ControlWinForms Shortcuts UI ControlWinForms SpellChecker UI ControlWinForms Track & Status UI ControlWinForms TreeView UI ControlWinForms Wizard UI ControlWinForms Test UI ControlWinForms Theme UI Control |