/// <summary> /// Adds an existing ColumnHeader to the collection. /// </summary> /// <param name="column">The ColumnHeader to /// add to the collection. </param> /// <returns>The zero-based index into the collection /// where the item was added.</returns> public int Add(ColumnHeaderEx column) { // Add the column to the base int retValue = base.Add (column); // Keep a refrence in columnList columnList.Add(column.ColumnID, column); // Add the its menu to main menu ContextMenu.MenuItems.Add(column.ColumnMenuItem); // Subscribe to the visiblity change event of the column column.VisibleChanged += new EventHandler(ColumnVisibleChanged); return retValue; }
/// <summary> /// This method is used to find the first visible column /// which is present in front of the column specified /// </summary> /// <param name="column">refrence columns for search</param> /// <returns>null if no visible colums are in front of /// the column specified, else previous columns returned</returns> private ColumnHeaderEx FindPreviousVisibleColumn(ColumnHeaderEx column) { // Get the position of the search column int index = columnList.IndexOfKey(column.ColumnID); if(index > 0) { // Start a recursive search for a visible column ColumnHeaderEx prevColumn = (ColumnHeaderEx)columnList.GetByIndex(index - 1); if((prevColumn != null) && (prevColumn.Visible == false)) { prevColumn = FindPreviousVisibleColumn(prevColumn); } return prevColumn; } // No visible columns found in font of specified column return null; }
/// <summary> /// Method adds a single column header to the collection. /// </summary> /// <param name="str">Text to display</param> /// <param name="width">Width of column</param> /// <param name="textAlign">Alignment</param> /// <returns>new ColumnHeaderEx added</returns> public override ColumnHeader Add(string str, int width, HorizontalAlignment textAlign) { ColumnHeaderEx column = new ColumnHeaderEx(str, width, textAlign); this.Add (column); return column; }