예제 #1
0
        public static void CreateSample(ref Grid grid1)
        {
            //Border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            //Views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.Khaki, Color.DarkKhaki);

            viewNormal.Border = cellBorder;
            CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(Color.Khaki, Color.DarkKhaki);

            viewCheckBox.Border = cellBorder;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor        = Color.Maroon;
            backHeader.Border           = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor  = Color.White;
            viewColumnHeader.Font       = new Font("Comic Sans MS", 10, FontStyle.Underline);

            //Editors
            SourceGrid.Cells.Editors.TextBox             editorString   = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));


            //Create the grid
            grid1.BorderStyle = BorderStyle.FixedSingle;

            grid1.ColumnsCount = 3;
            grid1.FixedRows    = 1;
            grid1.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("String");
            columnHeader.View = viewColumnHeader;
            grid1[0, 0]       = columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("DateTime");
            columnHeader.View = viewColumnHeader;
            grid1[0, 1]       = columnHeader;

            columnHeader      = new SourceGrid.Cells.ColumnHeader("CheckBox");
            columnHeader.View = viewColumnHeader;
            grid1[0, 2]       = columnHeader;

            for (int r = 1; r < 10; r++)
            {
                grid1.Rows.Insert(r);

                grid1[r, 0]        = new SourceGrid.Cells.Cell("Hello " + r.ToString());
                grid1[r, 0].Editor = editorString;

                grid1[r, 1]        = new SourceGrid.Cells.Cell(DateTime.Today);
                grid1[r, 1].Editor = editorDateTime;

                grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true);

                grid1[r, 0].View = viewNormal;
                grid1[r, 1].View = viewNormal;
                grid1[r, 2].View = viewCheckBox;
            }

            grid1.AutoSizeCells();
        }
예제 #2
0
        public static void Populate(ref Grid grid1, string[] cols, string[] colTyeNames, List <Hashtable> htList_WithKey
                                    , Color HeaderBackColor, Color cellBackColor, Color cellBackColorAlternate)
        {
            //Border
            DevAge.Drawing.BorderLine      border     = new DevAge.Drawing.BorderLine(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            //Views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(cellBackColor, cellBackColorAlternate);

            viewNormal.Border = cellBorder;
            CheckBoxBackColorAlternate viewCheckBox = new CheckBoxBackColorAlternate(cellBackColor, cellBackColorAlternate);

            viewCheckBox.Border = cellBorder;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader        viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader       = new DevAge.Drawing.VisualElements.ColumnHeader();

            backHeader.BackColor        = HeaderBackColor;
            backHeader.Border           = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor  = Color.White;
            viewColumnHeader.Font       = new Font("Comic Sans MS", 10, FontStyle.Underline);

            //Editors
            SourceGrid.Cells.Editors.TextBox             editorString   = new SourceGrid.Cells.Editors.TextBox(typeof(string));
            SourceGrid.Cells.Editors.TextBoxUITypeEditor editorDateTime = new SourceGrid.Cells.Editors.TextBoxUITypeEditor(typeof(DateTime));
            int colsLen = cols.Count();
            int rowsLen = htList_WithKey.Count;

            //Create the grid
            grid1.BorderStyle = BorderStyle.FixedSingle;

            grid1.ColumnsCount = colsLen;
            grid1.FixedRows    = 1;
            grid1.Rows.Clear();
            grid1.Rows.Insert(0);

            SourceGrid.Cells.ColumnHeader columnHeader;
            //header:
            for (int i = 0; i < colsLen; i++)
            {
                columnHeader      = new SourceGrid.Cells.ColumnHeader(cols[i]);
                columnHeader.View = viewColumnHeader;
                grid1[0, i]       = columnHeader;
            }
            //rows:
            for (int r = 1; r <= rowsLen; r++)
            {
                grid1.Rows.Insert(r);

                for (int c = 0; c < colsLen; c++)
                {
                    switch (colTyeNames[c])
                    {
                    case "CheckBox":
                        if (htList_WithKey[r - 1][cols[c]] != null)
                        {
                            if (htList_WithKey[r - 1][cols[c]].ToString() != "")
                            {
                                bool b = bool.Parse(htList_WithKey[r - 1][cols[c]].ToString());
                                grid1[r, c] = new SourceGrid.Cells.CheckBox(null, b);

                                grid1[r, c].View = viewCheckBox;
                            }
                        }
                        break;

                    case "CheckBoxVirtual":
                        if (htList_WithKey[r - 1][cols[c]] != null)
                        {
                            if (htList_WithKey[r - 1][cols[c]].ToString() != "")
                            {
                                bool b = false;
                                if (htList_WithKey[r - 1][cols[c]].ToString() == "11")
                                {
                                    b = true;
                                }

                                grid1[r, c] = new SourceGrid.Cells.CheckBox(null, b);

                                grid1[r, c].View = viewCheckBox;
                            }
                        }
                        break;

                    default:
                        if (htList_WithKey[r - 1][cols[c]] != null)
                        {
                            grid1[r, c] = new SourceGrid.Cells.Cell(htList_WithKey[r - 1][cols[c]].ToString());
                        }
                        else
                        {
                            grid1[r, c] = new SourceGrid.Cells.Cell("");
                        }

                        grid1[r, c].View = viewNormal;
                        break;
                    }
                }
            }
            grid1.AutoSizeCells();
        }