Esempio n. 1
0
        private MenuItem createMenuItemGroupShowHideColumns(DataTable dataTable)
        {
            var menuItemGroupColumns = new MenuItem("Show/Hide Columns");
            var dataColumns          = dataTable.Columns;

            for (int j = 0; j < dataColumns.Count; j++)
            {
                var menuItem = new MenuItem(dataColumns[j].ColumnName);
                menuItem.Checked = GridView.Columns[dataColumns[j].ColumnName].Visible;
                menuItem.Click  += toggleColumnVisibility;
                menuItem.Tag     = new MenuItemMetadata(MenuItemActionType.ColumnHeaderVisibility);
                menuItemGroupColumns.MenuItems.Add(menuItem);
            }

            _menuItemToggleVisibilityAllColumns        = new MenuItem("Toggle column visibility");
            _menuItemToggleVisibilityAllColumns.Click += menuItemToggleVisibilityAllColumns_Click;

            _menuItemShowAllColumns        = new MenuItem("Show all");
            _menuItemShowAllColumns.Click += showAllColumns_Click;

            _menuItemShowAllColumns.Enabled = !GridView.AllColumnsShown();

            menuItemGroupColumns.MenuItems.AddRange(new MenuItem[] { _separator,
                                                                     _menuItemShowAllColumns,
                                                                     _menuItemToggleVisibilityAllColumns });

            return(menuItemGroupColumns);
        }