예제 #1
0
        /// <summary>
        /// Handler to handel the visiblity change of columns
        /// </summary>
        /// <param name="sender">ColumnHeaderEx</param>
        /// <param name="e"></param>
        private void ColumnVisibleChanged(object sender, EventArgs e)
        {
            ColumnHeaderEx column = (ColumnHeaderEx)sender;

            if (column.Visible == true)
            {
                // Show the hidden column
                // Get the position where the hidden column has to be shown
                ColumnHeaderEx prevHeader = FindPreviousVisibleColumn(column);
                if (prevHeader == null)
                {
                    // This is the first column, so add it at 0 location
                    base.Insert(0, column);
                }
                else
                {
                    // Got the location, place it their.
                    base.Insert(prevHeader.Index + 1, column);
                }
            }
            else
            {
                // Hide the column.
                // Remove it from the base, dont worry we have the
                // refrence in columnList to get it back
                base.Remove(column);
            }
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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);
        }