private static void Reset(Grid a, int m, int n, HeaderColumnsHeader headerstate) { a.Redim(0, 0); switch (headerstate) { case HeaderColumnsHeader.both: a.Redim(m + 1, n + 1); a.FixedRows = 1; a.FixedColumns = 1; break; case HeaderColumnsHeader.columns: a.Redim(m, n + 1); a.FixedRows = 0; a.FixedColumns = 1; break; case HeaderColumnsHeader.rows: a.FixedRows = 1; a.FixedColumns = 0; a.Redim(m + 1, n); break; case HeaderColumnsHeader.none: a.FixedRows = 0; a.FixedColumns = 0; a.Redim(m, n); break; } }
public static void Fill(Grid a, double[] data, HeaderColumnsHeader header = HeaderColumnsHeader.both) { object[] temp = new object[data.Length]; data.CopyTo(temp, 0); switch (header) { case HeaderColumnsHeader.both: case HeaderColumnsHeader.rows: MakeGrid.Fill2(a, temp, Color.Snow, 1); break; case HeaderColumnsHeader.none: case HeaderColumnsHeader.columns: MakeGrid.Fill2(a, temp, Color.Snow, 0); break; } }
private static void Build(Grid a, int m, int n, Color warna, HeaderColumnsHeader headerstate = HeaderColumnsHeader.both, ResizeColumns autoresize = ResizeColumns.autocell, string pointzero = "#", string[] headername = null, int positionx = 0, int positiony = 0, SorterColumns sortable = SorterColumns.sort) { try { MakeGrid.Reset(a, m, n, headerstate); SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell(); SourceGrid.Cells.Editors.TextBox editor = new SourceGrid.Cells.Editors.TextBox(typeof(string)); view.BackColor = warna; if (headerstate == HeaderColumnsHeader.both || headerstate == HeaderColumnsHeader.rows) { for (int r = a.FixedRows; r < a.RowsCount; r++) { a[r, 0] = new SourceGrid.Cells.RowHeader(r); } } if (headerstate == HeaderColumnsHeader.both || headerstate == HeaderColumnsHeader.columns) { try { for (int c = a.FixedColumns; c < a.ColumnsCount; c++) { SourceGrid.Cells.ColumnHeader header = new SourceGrid.Cells.ColumnHeader(headername[c - 1]); header.AutomaticSortEnabled = true; header.View.TextAlignment = ContentAlignment.MiddleCenter; a[0, c] = header; } } catch { } } SourceGrid.Cells.ColumnHeader header1 = new SourceGrid.Cells.ColumnHeader(pointzero); if (sortable == SorterColumns.sort) { header1.SortComparer = new SourceGrid.MultiColumnsComparer(1, 2, 3, 4); } a[0, 0] = header1; for (int r = a.FixedRows; r < a.RowsCount; r++) { for (int c = a.FixedColumns; c < a.ColumnsCount; c++) { a[r, c] = new SourceGrid.Cells.Cell(""); a[r, c].Editor = editor; a[r, c].View = view; } } a.Update(); a.Selection.Focus(new SourceGrid.Position(positionx, positiony), true); if (autoresize == ResizeColumns.autocell) { a.AutoSizeCells(); } } catch { } }
public static void Build(Grid a, int m, int n, HeaderColumnsHeader header) { Build(a, m, n, Color.Snow, header); }