BrightIdeasSoftware.ObjectListView.AddItemsToColumnSelectMenu C# (CSharp) Method

AddItemsToColumnSelectMenu() protected method

Create the menu items that will allow columns to be choosen and add them to the given collection
protected AddItemsToColumnSelectMenu ( ToolStripItemCollection items ) : void
items System.Windows.Forms.ToolStripItemCollection
return void
        protected void AddItemsToColumnSelectMenu(ToolStripItemCollection items)
        {
            // Sort columns by display order
            List<OLVColumn> columns = new List<OLVColumn>(this.AllColumns);
            columns.Sort(delegate(OLVColumn x, OLVColumn y) { return (x.LastDisplayIndex - y.LastDisplayIndex); });

            // Build menu from sorted columns
            foreach (OLVColumn col in columns) {
                ToolStripMenuItem mi = new ToolStripMenuItem(col.Text);
                mi.Checked = col.IsVisible;
                mi.Tag = col;

                // The 'Index' property returns -1 when the column is not visible, so if the
                // column isn't visible we have to enable the item. Also the first column can't be turned off
                mi.Enabled = !col.IsVisible || col.CanBeHidden;
                items.Add(mi);
            }
        }
ObjectListView