/// <summary> /// Add column /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddColumn_Click(object sender, EventArgs e) { if (!AllowColumnModifications()) { return; } int r = View.FocusedRowHandle; if (r < 0) { return; } if (UserDatabase && r == 0) { r = 1; // keep key & structure as 1st 2 cols } r++; // index of new row DataRow dr = ColGridDataTable.NewRow(); //dr["CustomFormat"] = new Bitmap(1, 1); dr["DisplayByDefault"] = true; ColGridDataTable.Rows.InsertAt(dr, r); View.FocusedRowHandle = r; View.FocusedColumn = View.Columns[0]; View.ShowEditor(); }
private void MoveColumnDown_Click(object sender, EventArgs e) { if (!AllowColumnModifications()) { return; } int r = View.FocusedRowHandle; if (r < 0) { return; } if ((AnnotationTable && r <= 0) || (UserDatabase && r <= 1) || // keep initial col position(s) as is r >= View.RowCount - 1) { MessageBoxMx.Show("This column can't be moved down."); return; } DataRow dr = ColGridDataTable.NewRow(); dr.ItemArray = ColGridDataTable.Rows[r].ItemArray; ColGridDataTable.Rows.RemoveAt(r); ColGridDataTable.Rows.InsertAt(dr, r + 1); View.FocusedRowHandle = r + 1; return; }
private void ColGridView_MouseDown(object sender, MouseEventArgs e) { Point p; Rectangle rect; string txt; int qtCi, ri, ci; if (View == null) { return; } p = new Point(e.X, e.Y); GridHitInfo ghi = View.CalcHitInfo(p); if (ghi == null) { return; } ri = ghi.RowHandle; if (ghi.Column == null) { return; } GridColumn gc = ghi.Column; GridViewInfo viewInfo = View.GetViewInfo() as GridViewInfo; GridCellInfo gci = viewInfo.GetGridCellInfo(ghi); if (gci == null) { return; } ri = ghi.RowHandle; if (ri == GridControl.NewItemRowHandle) // click in virtual new row? { DataRow dr = ColGridDataTable.NewRow(); ColGridDataTable.Rows.Add(dr); DelayedCallback.Schedule(ClickedInNewRow, gc); // schedule callback for after grid rendered with new row return; } if (ri >= ColGridDataTable.Rows.Count) { return; } CurrentRow = ri; if (Lex.Eq(gc.Name, "CustomFormat")) // Show format col { MetaColumn mc = GetMetaColumnFromColGridDataTableRow(ColGridDataTable.Rows[ri]); if (mc == null) { return; } ColumnFormattingContextMenu.Show(ColGrid, p); this.Refresh(); return; } return; }