Exemple #1
0
        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
            {
            }
        }
Exemple #2
0
 public static void Build(Grid a, int m, int n, ResizeColumns resizecolumn, params string[] headername)
 {
     Build(a, m, n, Color.Snow, HeaderColumnsHeader.both, resizecolumn, "#", headername);
 }