Represents a column of DataGridViewControlCells in a CollapsibleDataGridView.
Inheritance: System.Windows.Forms.DataGridViewColumn
        protected override void OnMouseUp(MouseEventArgs e)
        {
            HitTestInfo info = HitTest(e.X, e.Y);

            if (info.Type == DataGridViewHitTestType.Cell)
            {
                DataGridViewControlColumn column = Columns[info.ColumnIndex] as DataGridViewControlColumn;
                column.StandardWidth = column.Width;
                if (e.X < column.ThresholdWidth && e.X > DataGridViewControlColumn.kMinimumValue)
                {
                    e = new MouseEventArgs(e.Button, e.Clicks, column.ThresholdWidth, e.Y, e.Delta);
                }
            }

            base.OnMouseUp(e);

            // Hide all the rows and columns that are to small now
            foreach (DataGridViewBand band in m_ColumnsAndRowsToHide)
            {
                band.Visible = false;
            }
            m_ColumnsAndRowsToHide.Clear();

            for (int iColumn = 0; iColumn < ColumnCount; iColumn++)
            {
                DataGridViewControlColumn col = Columns[iColumn] as DataGridViewControlColumn;

                // The current column can occupy a maximum percentage of the remaining width
                // (calculated as width from the left edge of the column to the right edge of
                // the grid) - except the last column which can occupy max percentage of the
                // entire width.
                // TODO-Linux: GetColumnDisplayRectangle() does not use cutOverflow parameter on Mono.
                Rectangle colRect        = GetColumnDisplayRectangle(iColumn, false);
                int       remainingWidth = (iColumn == ColumnCount - 1) ? Width : Width - colRect.Left;
#if !__MonoCS__
                if (col.MaxPercentage > 0 && col.MaxPercentage < (float)col.Width / (float)remainingWidth)
                {
                    col.Width = (int)(col.MaxPercentage * remainingWidth);
                }
#else
                // TODO-Linux: On mono Col.Width can somtimes be set to less than Minimum - This may be because
                // When resizing cells .NET restricts the drag to the Minimum level
                // Could submit a bug/Enhancement for this.
                int valueToSet = (int)(col.MaxPercentage * remainingWidth);
                if (col.MaxPercentage > 0 && col.MaxPercentage < (float)col.Width / (float)remainingWidth)
                {
                    if (valueToSet > col.MinimumWidth)
                    {
                        col.Width = valueToSet;
                    }
                    else
                    {
                        Console.WriteLine("!!!! CollapsibleDataGrid Bug Attempting to set width smaller than min!");
                        col.Width = col.MinimumWidth;
                    }
                }
#endif
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates an exact copy of this column.
        /// </summary>
        /// <returns>An object that represents the cloned DataGridViewControlColumn.</returns>
        /// ------------------------------------------------------------------------------------
        public override object Clone()
        {
            DataGridViewControlColumn column = base.Clone() as DataGridViewControlColumn;

            column.m_fIsCollapsible = m_fIsCollapsible;
            column.m_MaxPercentage  = m_MaxPercentage;
            column.m_StandardWidth  = m_StandardWidth;
            column.m_ThresholdWidth = m_ThresholdWidth;
            return(column);
        }
Beispiel #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:SplitGrid"/> class.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="styleSheet">The style sheet.</param>
        /// <param name="columns">The number of columns.</param>
        /// <param name="rows">The number of rows.</param>
        /// ------------------------------------------------------------------------------------
        public SplitGrid(FdoCache cache, IVwStylesheet styleSheet, int rows, int columns)
        {
            m_cache        = cache;
            m_StyleSheet   = styleSheet;
            m_grid         = CreateDataGridView();
            m_defaultGroup = new RootSiteGroup(this);
            m_groups.Add(m_defaultGroup);
            m_activeViewHelper = new ActiveViewHelper(this);
            BorderStyle        = BorderStyle.None;

            SuspendLayout();
            m_grid.Dock                        = DockStyle.Fill;
            m_grid.BackgroundColor             = SystemColors.Control;
            m_grid.BorderStyle                 = BorderStyle.None;
            m_grid.AutoSizeColumnsMode         = DataGridViewAutoSizeColumnsMode.Fill;
            m_grid.SelectionMode               = DataGridViewSelectionMode.CellSelect;
            m_grid.RowHeadersVisible           = false;
            m_grid.ColumnHeadersVisible        = false;
            m_grid.AllowUserToAddRows          = false;
            m_grid.AllowUserToDeleteRows       = false;
            m_grid.AllowUserToOrderColumns     = false;
            m_grid.AdvancedCellBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Outset;
            m_grid.AdvancedCellBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
            m_grid.ScrollBars                  = ScrollBars.None;
            m_grid.RowStateChanged            += new DataGridViewRowStateChangedEventHandler(OnRowStateChanged);
            m_grid.ColumnStateChanged         += new DataGridViewColumnStateChangedEventHandler(OnColumnStateChanged);
            m_grid.MouseDown                  += new MouseEventHandler(OnGridMouseDown);
            m_grid.MouseUp                    += new MouseEventHandler(OnGridMouseUp);
            m_grid.RowTemplate                 = new DataGridViewControlRow();

            for (int i = 0; i < columns; i++)
            {
                DataGridViewControlColumn column = new DataGridViewControlColumn(i == columns - 1);
                m_grid.Columns.Add(column);
            }
            m_MaxRows = rows;
            Controls.Add(m_grid);
            ResumeLayout(true);

            m_grid.BringToFront();
            Visible = false;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that
        /// contains the event data.</param>
        /// ------------------------------------------------------------------------------------
        protected override void OnMouseUp(MouseEventArgs e)
        {
            HitTestInfo info = HitTest(e.X, e.Y);

            if (info.Type == DataGridViewHitTestType.Cell)
            {
                DataGridViewControlColumn column = Columns[info.ColumnIndex] as DataGridViewControlColumn;
                column.StandardWidth = column.Width;
                if (e.X < column.ThresholdWidth && e.X > DataGridViewControlColumn.kMinimumValue)
                {
                    e = new MouseEventArgs(e.Button, e.Clicks, column.ThresholdWidth, e.Y, e.Delta);
                }
            }

            base.OnMouseUp(e);

            // Hide all the rows and columns that are to small now
            foreach (DataGridViewBand band in m_ColumnsAndRowsToHide)
            {
                band.Visible = false;
            }
            m_ColumnsAndRowsToHide.Clear();

            for (int iColumn = 0; iColumn < ColumnCount; iColumn++)
            {
                DataGridViewControlColumn col = Columns[iColumn] as DataGridViewControlColumn;

                // The current column can occupy a maximum percentage of the remaining width
                // (calculated as width from the left edge of the column to the right edge of
                // the grid) - except the last column which can occupy max percentage of the
                // entire width.
                Rectangle colRect        = GetColumnDisplayRectangle(iColumn, false);
                int       remainingWidth = (iColumn == ColumnCount - 1) ? Width : Width - colRect.Left;
                if (col.MaxPercentage > 0 && col.MaxPercentage < (float)col.Width / (float)remainingWidth)
                {
                    col.Width = (int)(col.MaxPercentage * remainingWidth);
                }
            }
        }
Beispiel #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:SplitGrid"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="columns">The number of columns.</param>
		/// <param name="rows">The number of rows.</param>
		/// ------------------------------------------------------------------------------------
		public SplitGrid(FdoCache cache, IVwStylesheet styleSheet, int rows, int columns)
		{
			m_cache = cache;
			m_StyleSheet = styleSheet;
			m_grid = CreateDataGridView();
			m_defaultGroup = new RootSiteGroup(this);
			m_groups.Add(m_defaultGroup);
			m_activeViewHelper = new ActiveViewHelper(this);
			BorderStyle = BorderStyle.None;

			SuspendLayout();
			m_grid.Dock = DockStyle.Fill;
			m_grid.BackgroundColor = SystemColors.Control;
			m_grid.BorderStyle = BorderStyle.None;
			m_grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
			m_grid.SelectionMode = DataGridViewSelectionMode.CellSelect;
			m_grid.RowHeadersVisible = false;
			m_grid.ColumnHeadersVisible = false;
			m_grid.AllowUserToAddRows = false;
			m_grid.AllowUserToDeleteRows = false;
			m_grid.AllowUserToOrderColumns = false;
			m_grid.AdvancedCellBorderStyle.All = DataGridViewAdvancedCellBorderStyle.Outset;
			m_grid.AdvancedCellBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None;
			m_grid.ScrollBars = ScrollBars.None;
			m_grid.RowStateChanged += new DataGridViewRowStateChangedEventHandler(OnRowStateChanged);
			m_grid.ColumnStateChanged += new DataGridViewColumnStateChangedEventHandler(OnColumnStateChanged);
			m_grid.MouseDown += new MouseEventHandler(OnGridMouseDown);
			m_grid.MouseUp += new MouseEventHandler(OnGridMouseUp);
			m_grid.RowTemplate = new DataGridViewControlRow();

			for (int i = 0; i < columns; i++)
			{
				DataGridViewControlColumn column = new DataGridViewControlColumn(i == columns - 1);
				m_grid.Columns.Add(column);
			}
			m_MaxRows = rows;
			Controls.Add(m_grid);
			ResumeLayout(true);

			m_grid.BringToFront();
			Visible = false;
		}