Example #1
0
        /// <summary> Remove a column</summary>
        public void RemoveColumn(int column)
        {
            foreach (var r in rows)
            {
                r.RemoveCellAt(column);      // this will cause lots of row changed cells, causing an Invalidate.
            }
            GLDataGridViewColumn col = columns[column];

            col.Parent              = null;
            col.HeaderStyle.Parent  = null;
            col.HeaderStyle.Changed = null;
            col.Changed             = null;
            columns.RemoveAt(column);

            if (SortColumn == column)
            {
                SortColumn = -1;
            }

            for (int i = 0; i < columns.Count; i++)
            {
                columns[i].SetColNo(i);
            }

            autosizegeneration++;           // force autosize as we changed columns
            ContentInvalidateLayout();
        }
Example #2
0
        /// <summary> Create a column. Columns must be created via this call. </summary>
        /// <param name="width">Column width in pixels</param>
        /// <param name="fillwidth">Column fill width</param>
        /// <param name="minwidth">Column minimum width in pixels</param>
        /// <param name="title">Column title</param>
        public GLDataGridViewColumn CreateColumn(int width = 50, int fillwidth = 100, int minwidth = 10, string title = "")
        {
            GLDataGridViewColumn col = new GLDataGridViewColumn();

            col.HeaderStyle.Parent = colheaderstyle;
            col.Parent             = this;
            col.Width        = width;
            col.FillWidth    = fillwidth;
            col.MinimumWidth = minwidth;
            col.Text         = title;
            return(col);
        }
Example #3
0
 /// <summary> Add a Column (at the end) to the grid </summary>
 public void AddColumn(GLDataGridViewColumn col)
 {
     System.Diagnostics.Debug.Assert(col.Parent == this && col.HeaderStyle.Parent != null);      // ensure created by us
     col.HeaderStyle.Changed += (e1) => { colheaderpanel.Invalidate(); };
     col.Changed             += (e1, ci) =>
     {
         if (ci)                   // if set, it means width has changed in some way
         {
             autosizegeneration++; // force autosize as we changed width
             ContentInvalidateLayout();
         }
         else
         {
             colheaderpanel.Invalidate();
         }
     };
     col.SetColNo(columns.Count);
     columns.Add(col);
     autosizegeneration++;           // force autosize as we changed columns
     ContentInvalidateLayout();
 }