예제 #1
1
        private void Form1_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(10, 5);
            grid1.SelectionMode = SourceGrid.GridSelectionMode.Row;

            //Setup the controllers
            CellClickEvent clickController  = new CellClickEvent();
            PopupMenu      menuController   = new PopupMenu();
            CellCursor     cursorController = new CellCursor();

            SourceGrid.Cells.Controllers.ToolTipText toolTipController = new SourceGrid.Cells.Controllers.ToolTipText();
            toolTipController.ToolTipTitle = "ToolTip example";
            toolTipController.ToolTipIcon  = ToolTipIcon.Info;
            toolTipController.IsBalloon    = true;
            ValueChangedEvent valueChangedController = new ValueChangedEvent();

            for (int r = 0; r < grid1.Rows.Count; r++)
            {
                if (r == 0)
                {
                    grid1[r, 0] = new SourceGrid.Cells.ColumnHeader("Click event");
                    grid1[r, 1] = new SourceGrid.Cells.ColumnHeader("Custom Cursor");
                    grid1[r, 2] = new SourceGrid.Cells.ColumnHeader("ContextMenu");
                    grid1[r, 3] = new SourceGrid.Cells.ColumnHeader("ToolTip");
                    grid1[r, 4] = new SourceGrid.Cells.ColumnHeader("ValueChanged");
                }
                else
                {
                    grid1[r, 0]             = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string));
                    grid1[r, 1]             = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));
                    grid1[r, 2]             = new SourceGrid.Cells.Cell("Right click");
                    grid1[r, 3]             = new SourceGrid.Cells.Cell("Value " + r.ToString());
                    grid1[r, 3].ToolTipText = "Example of tooltip, bla bla bla ....\n Row: " + r.ToString();
                    grid1[r, 4]             = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string));
                }

                grid1[r, 0].AddController(clickController);
                grid1[r, 1].AddController(cursorController);
                grid1[r, 2].AddController(menuController);
                grid1[r, 3].AddController(toolTipController);
                grid1[r, 4].AddController(valueChangedController);
            }

            grid1.AutoSizeCells();

            //Add the key controller to all the cells
            grid1.Controller.AddController(new KeyEvent(this));
        }
예제 #2
0
        void updateGrid(SourceGrid.Grid grid)
        {
            foreach (SourceGrid.GridRow row in grid.Rows)
            {
                var node = row.Tag as NodeTable;
                if (node != null)
                {
                    GenTable tb = node.Item;

                    if (tb.TableName.ToUpper().StartsWith("VW"))
                    {
                        ToString();
                    }

                    int r = row.Index;
                    if (tb.TableName == "AddressType")
                    {
                        ToString();
                    }
                    tb.CheckEnum();
                    grid[r, 0].Value = tb.SchemaName;
                    grid[r, 1].Value = tb.TableName;
                    grid[r, 2].Value = tb.DataClassName;
                    grid[r, 3].Value = tb.BusinessClassName;
                    grid[r, 4].Value = tb.EnumColumnName;
                    grid[r, 5].Value = tb.EnumColumnId;
                    grid[r, 6].Value = tb.EnumName;
                    grid[r, 7].Value = tb.SequenceColumn;
                    grid[r, 8].Value = tb.SequenceName;
                    grid[r, 9].Value = tb.DataAnnotation;
                    //grid[r, 5].Value = tb.SubDirectory;
                }
            }
            grid.AutoSizeCells();
        }
예제 #3
0
        public void GridBindData(SourceGrid.Grid urlGrid)
        {
            urlGrid.Rows.Clear();
            urlGrid.Rows.Insert(0);

            urlGrid[0, 0] = new SourceGrid.Cells.ColumnHeader("URL");
            urlGrid[0, 1] = new SourceGrid.Cells.ColumnHeader("Sync\nPosition");
            urlGrid[0, 2] = new SourceGrid.Cells.ColumnHeader("Sync\nScreenshots");

            int r = 1;

            foreach (SyncURL syncURL in _settings.syncURLs)
            {
                urlGrid.Rows.Insert(r);
                urlGrid[r, 0]        = new SourceGrid.Cells.Cell(syncURL.URL, typeof(string));
                urlGrid[r, 0].Editor = null;
                urlGrid[r, 1]        = new SourceGrid.Cells.CheckBox(null, syncURL.syncPosition);
                urlGrid[r, 1].Editor = null;
                urlGrid[r, 2]        = new SourceGrid.Cells.CheckBox(null, syncURL.syncScreenshot);
                urlGrid[r, 2].Editor = null;
                urlGrid[r, 3]        = new SourceGrid.Cells.Button("Edit");
                urlGrid[r, 3].Editor = null;
                urlGrid[r, 3].AddController(gridEditEvent);
                urlGrid[r, 4]        = new SourceGrid.Cells.Button("Delete");
                urlGrid[r, 4].Editor = null;
                urlGrid[r, 4].AddController(gridDeleteEvent);

                urlGrid[r, 5] = new SourceGrid.Cells.Cell(syncURL.id, typeof(string));

                r++;
            }

            urlGrid.AutoSizeCells();
        }
예제 #4
0
        void updateGrid(SourceGrid.Grid grid)
        {
            foreach (SourceGrid.GridRow row in grid.Rows)
            {
                var node = row.Tag as NodeTable;
                if (node != null)
                {
                    GenTable tb = node.Item;

                    if (tb.TableName.ToUpper().StartsWith("VW"))
                    {
                        ToString();
                    }

                    int r = row.Index;
                    tb.CheckEnum();
                    grid[r, Col.SchemaName].Value        = tb.SchemaName;
                    grid[r, Col.TableName].Value         = tb.TableName;
                    grid[r, Col.DataClassName].Value     = tb.DataClassName;
                    grid[r, Col.BusinessClassName].Value = tb.BusinessClassName;
                    grid[r, Col.EnumColumnName].Value    = tb.EnumColumnName;
                    grid[r, Col.EnumColumnId].Value      = tb.EnumColumnId;
                    grid[r, Col.EnumName].Value          = tb.EnumName;
                    grid[r, Col.EnumAttributes].Value    = tb.EnumAttributes;
                    grid[r, Col.SequenceColumn].Value    = tb.SequenceColumn;
                    grid[r, Col.SequenceName].Value      = tb.SequenceName;
                    grid[r, Col.Attributes].Value        = tb.Attributes;
                    //grid[r, 5].Value = tb.SubDirectory;
                }
            }
            grid.AutoSizeCells();
        }
예제 #5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            grid1.ColumnsCount = 2;

            SourceGrid.Cells.Controllers.Button linkEvents = new SourceGrid.Cells.Controllers.Button();
            linkEvents.Executed += new EventHandler(linkEvents_Executed);

            SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell();
            categoryView.BackColor     = Color.FromKnownColor(KnownColor.ActiveCaption);
            categoryView.ForeColor     = Color.FromKnownColor(KnownColor.ActiveCaptionText);
            categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            Type[] types = assembly.GetTypes();

            LoadCategorySample("SourceGrid - Basic concepts", linkEvents, types, categoryView);
            LoadCategorySample("SourceGrid - Standard features", linkEvents, types, categoryView);
            LoadCategorySample("SourceGrid - Advanced features", linkEvents, types, categoryView);
            LoadCategorySample("SourceGrid - Extensions", linkEvents, types, categoryView);
            LoadCategorySample("SourceGrid - Generic Samples", linkEvents, types, categoryView);

            //Stretch only the last column
            grid1.Columns[0].AutoSizeMode      = SourceGrid.AutoSizeMode.EnableAutoSize;
            grid1.Columns[1].AutoSizeMode      = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch;
            grid1.AutoStretchColumnsToFitWidth = true;
            grid1.AutoSizeCells();
            grid1.Columns.StretchToFit();
        }
예제 #6
0
        private void InitializeGrid(object sender, System.EventArgs e)
        {
            grid1.BorderStyle  = BorderStyle.FixedSingle;
            grid1.ColumnsCount = 3;

            // create header
            grid1.Rows.Insert(0);
            grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("RichTextBox");
            grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("RichTextBox");
            grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("RichTextBox");

            // create 10 rows
            for (Int32 r = 1; r < 10; r++)
            {
                grid1.Rows.Insert(r);

                // create three columns
                for (Int32 c = 0; c < 3; c++)
                {
                    // create richTextBox
                    SourceGrid.Cells.RichTextBox         richTextBox     = CreateRichTextBox();
                    SourceGrid.Cells.Views.RichTextBox   richTextBoxView = CreateRichTextBoxView();
                    SourceGrid.Cells.Editors.RichTextBox editor          = new SourceGrid.Cells.Editors.RichTextBox();
                    editor.Control.Multiline = true;
                    grid1[r, c]        = richTextBox;
                    grid1[r, c].Editor = editor;
                    grid1[r, c].View   = richTextBoxView;
                }
            }

            grid1.AutoSizeCells();
        }
예제 #7
0
        private void Form1_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(10, 3);

            CellClickEvent clickController  = new CellClickEvent();
            PopupMenu      menuController   = new PopupMenu();
            CellCursor     cursorController = new CellCursor();

            for (int r = 0; r < grid1.Rows.Count; r++)
            {
                if (r == 0)
                {
                    grid1[r, 0] = new SourceGrid.Cells.ColumnHeader("Click event");
                    grid1[r, 1] = new SourceGrid.Cells.ColumnHeader("Custom Cursor");
                    grid1[r, 2] = new SourceGrid.Cells.ColumnHeader("ContextMenu");
                }
                else
                {
                    grid1[r, 0] = new SourceGrid.Cells.Cell("Value " + r.ToString(), typeof(string));
                    grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Now, typeof(DateTime));
                    grid1[r, 2] = new SourceGrid.Cells.Cell("Right click");
                }

                grid1[r, 0].AddController(clickController);
                grid1[r, 1].AddController(cursorController);
                grid1[r, 2].AddController(menuController);
            }

            grid1.AutoSizeCells();
        }
예제 #8
0
        private void frmSample14_Load(object sender, System.EventArgs e)
        {
            grid.BorderStyle = BorderStyle.FixedSingle;

            grid.ColumnsCount = 4;
            grid.FixedRows    = 1;
            grid.Rows.Insert(0);

            SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
            cbEditor.StandardValues = new string[] { "Value 1", "Value 2", "Value 3" };
            cbEditor.EditableMode   = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;

            grid[0, 0] = new SourceGrid.Cells.ColumnHeader("String");
            grid[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime");
            grid[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox");
            grid[0, 3] = new SourceGrid.Cells.ColumnHeader("ComboBox");
            for (int r = 1; r < 10; r++)
            {
                grid.Rows.Insert(r);
                grid[r, 0]      = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string));
                grid[r, 1]      = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime));
                grid[r, 2]      = new SourceGrid.Cells.CheckBox(null, true);
                grid[r, 3]      = new SourceGrid.Cells.Cell("Value 1", cbEditor);
                grid[r, 3].View = SourceGrid.Cells.Views.ComboBox.Default;
            }

            grid.AutoSizeCells();
        }
예제 #9
0
 public void GridAddRows <T>(
     SourceGrid.Grid grid,
     List <T> List,
     Func <T, Color, GridCellController> newCellController = null)
 {
     if (List != null)
     {
         int index = grid.RowsCount;
         for (int i = 0; i < List.Count; i++)
         {
             GridInsertRow(grid, List[i], newCellController);
         }
     }
     grid.AutoSizeCells();
 }
예제 #10
0
        private void GridFinalize(SourceGrid.Grid grid)
        {
            grid.AutoStretchColumnsToFitWidth = true;
            grid.AutoSizeCells();
            grid.Columns.StretchToFit();

            // select first solution
            if (grid.RowsCount > 1)
            {
                grid.Selection.SelectRow(1, true);
            }
            else
            {
                // grid empty -> clear drawing
                _selectedItem = null;
                graphCtrl.Invalidate();
            }
        }
예제 #11
0
        private void frmSample46_Load(object sender, System.EventArgs e)
        {
            grid1.BorderStyle = BorderStyle.FixedSingle;

            grid1.ColumnsCount = 3;
            grid1.FixedRows    = 1;
            grid1.Rows.Insert(0);
            grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("String");
            grid1[0, 1] = new SourceGrid.Cells.ColumnHeader("DateTime");
            grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("CheckBox");
            for (int r = 1; r < 10; r++)
            {
                grid1.Rows.Insert(r);
                grid1[r, 0] = new SourceGrid.Cells.Cell("Hello " + r.ToString(), typeof(string));
                grid1[r, 1] = new SourceGrid.Cells.Cell(DateTime.Today, typeof(DateTime));
                grid1[r, 2] = new SourceGrid.Cells.CheckBox(null, true);
            }

            grid1.AutoSizeCells();
        }
예제 #12
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            grid1.ColumnsCount = 2;

            SourceGrid.Cells.Controllers.Button linkEvents = new SourceGrid.Cells.Controllers.Button();
            linkEvents.Executed += new EventHandler(linkEvents_Executed);

            //Category header
            SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell();
            categoryView.Background    = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.RoyalBlue, Color.LightBlue, 0);
            categoryView.ForeColor     = Color.FromKnownColor(KnownColor.ActiveCaptionText);
            categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            categoryView.Border        = DevAge.Drawing.RectangleBorder.NoBorder;
            categoryView.Font          = new Font(Font, FontStyle.Bold);

            //Title header
            SourceGrid.Cells.Views.ColumnHeader headerView = new SourceGrid.Cells.Views.ColumnHeader();


            //Load the forms
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            Type[] types = assembly.GetTypes();

            LoadCategorySample("SourceGrid - Basic concepts", linkEvents, types, categoryView, headerView);
            LoadCategorySample("SourceGrid - Standard features", linkEvents, types, categoryView, headerView);
            LoadCategorySample("SourceGrid - Advanced features", linkEvents, types, categoryView, headerView);
            LoadCategorySample("SourceGrid - Extensions", linkEvents, types, categoryView, headerView);
            LoadCategorySample("SourceGrid - Generic Samples", linkEvents, types, categoryView, headerView);
            LoadCategorySample("SourceGrid - Performance", linkEvents, types, categoryView, headerView);
            LoadCategorySample("SourceGrid - PingGrid", linkEvents, types, categoryView, headerView);

            //Stretch only the last column
            grid1.Columns[0].AutoSizeMode      = SourceGrid.AutoSizeMode.EnableAutoSize;
            grid1.Columns[1].AutoSizeMode      = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch;
            grid1.AutoStretchColumnsToFitWidth = true;
            grid1.AutoSizeCells();
            grid1.Columns.StretchToFit();
        }
예제 #13
0
        private void frmSample19_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(20, 20);

            grid1.BackgroundImage           = Properties.Resources.BackGround;
            grid1.ScrollablePanel.BackColor = Color.Transparent;

            Random rnd = new Random();

            SourceGrid.Cells.Views.Cell transparentView = new SourceGrid.Cells.Views.Cell();
            transparentView.BackColor = Color.Transparent;
            SourceGrid.Cells.Views.Cell semiTransparentView = new SourceGrid.Cells.Views.Cell();
            semiTransparentView.BackColor = Color.FromArgb(50, Color.Blue);

            for (int r = 0; r < grid1.RowsCount; r++)
            {
                for (int c = 0; c < grid1.ColumnsCount; c++)
                {
                    if (rnd.Next(0, 100) < 50)
                    {
                        grid1[r, c] = new SourceGrid.Cells.Cell("Opaque");
                    }
                    else if (rnd.Next(0, 100) < 75)
                    {
                        SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent");
                        l_Cell.View = transparentView;
                        grid1[r, c] = l_Cell;
                    }
                    else
                    {
                        SourceGrid.Cells.Cell l_Cell = new SourceGrid.Cells.Cell("Transparent 50");
                        l_Cell.View = semiTransparentView;
                        grid1[r, c] = l_Cell;
                    }
                }
            }

            grid1.AutoSizeCells();
        }
예제 #14
0
        /// <summary>
        /// Populate this SourceGrid object with the list of typed objects given.
        /// Specific properties are fetched from each object and displayed in the relevant columns.
        /// </summary>
        /// <param name="headers">The column headers to display in the first row. Array length must match rowProps</param>
        /// <param name="rows">The list of typed objects to display</param>
        /// <param name="rowProps">The names of properties or paths to fetch from each object. Array length must match headers</param>
        public static void SetCells <T>(this SourceGrid.Grid grid, IList <string> headers, IList <T> rows, IList <string> rowProps)
        {
            // clear prev data
            grid.Rows.Clear();

            // configure grid
            grid.ColumnsCount = headers.Count;
            grid.FixedRows    = 1;
            grid.Rows.Insert(0);
            int frc = grid.FixedRows;

            // set headers
            int h = 0;

            foreach (var header in headers)
            {
                grid[0, h++] = new SourceGrid.Cells.ColumnHeader(header);
            }

            // set cells
            if (rows != null)
            {
                for (int y = 0; y < rows.Count; y++)
                {
                    grid.Rows.Insert(y + 1);
                    T row = rows[y];
                    for (int x = 0; x < headers.Count; x++)
                    {
                        var value = (row.GetPropValue(rowProps[x]) ?? "").ToString();
                        grid[y + frc, x] = new SourceGrid.Cells.Cell(value);
                    }
                }
            }

            // autosize all columns & rows
            grid.AutoSizeCells();
        }
예제 #15
0
        void LoadTables(Database db, SourceGrid.Grid grid, string title, string nameTitle, NodeBase tableViewNode)
        {
            var tc = new TimerCount("LoadTables");

            grid.BorderStyle   = BorderStyle.FixedSingle;
            grid.SelectionMode = SourceGrid.GridSelectionMode.Cell;
            grid.ClipboardMode = SourceGrid.ClipboardMode.All;

            grid.Rows.Clear();
            grid.Columns.Clear();

            grid.ColumnsCount = 11;
            grid.FixedRows    = 1;
            grid.FixedColumns = 2;

            //int r = 0;
            SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell();
            categoryView.Background    = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.Gainsboro, Color.WhiteSmoke, 0);
            categoryView.ForeColor     = Color.Black;
            categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            categoryView.Border        = DevAge.Drawing.RectangleBorder.NoBorder;
            categoryView.Font          = new Font(Font, FontStyle.Bold);

            //grid.Rows.Insert(r);
            //grid[r, 0] = new SourceGrid.Cells.Cell(title);
            //grid[r, 0].View = categoryView;
            //grid[r, 0].ColumnSpan = grid.ColumnsCount;

            //r++;
            int r = 0;

            grid.Rows.Insert(r);
            headerView = new SourceGrid.Cells.Views.Cell();
            //headerView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.Gainsboro, Color.WhiteSmoke, 0);
            headerView.ForeColor     = Color.FromKnownColor(KnownColor.Black);
            headerView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            headerView.Border        = DevAge.Drawing.RectangleBorder.NoBorder;
            headerView.Font          = new Font(Font, FontStyle.Bold);

            addHeader(grid, Col.SchemaName, "Schema Name", 100);
            addHeader(grid, Col.TableName, "Table Name", 150);
            addHeader(grid, Col.DataClassName, "DataClass Name", 150);
            addHeader(grid, Col.BusinessClassName, "BusinessClass Name", 150);
            addHeader(grid, Col.EnumColumnName, "Enum Column Name", 150);
            addHeader(grid, Col.EnumColumnId, "Enum Column Id", 150);
            addHeader(grid, Col.EnumName, "Enum Name", 150);
            addHeader(grid, Col.EnumAttributes, "Enum Attributes", 150);
            addHeader(grid, Col.SequenceColumn, "Sequence Column", 150);
            addHeader(grid, Col.SequenceName, "Sequence Name", 150);
            addHeader(grid, Col.Attributes, "Attributes", 300);
            //addHeader(grid, 5, "Sub-directory", 150);

            for (int c = 0; c < grid.ColumnsCount; c++)
            {
                grid[r, c].View = categoryView;
            }

            Dictionary <string, GenTable> objects = new Dictionary <string, GenTable>();

            tc.Next("GetSequences");
            var sequences = db.Provider.GetSequences();

            r++;

            foreach (NodeTable node in tableViewNode.Nodes)
            {
                progress.SetProgress();
                //progress.SetProgress("Processing table" + node.Text + " ...");

                var gtb = node.Item;
                if (gtb.TableName == "status")
                {
                    ToString();
                }

                objects.Add(gtb.FullName, null);

                tc.Next(gtb.TableName);

                try
                {
                    //tc.Next("GetTableInfo");
                    //var tb = db.GetTableInfo(gtb.SchemaName, gtb.TableName);
                    var tbCols = db.GetColumnsInfo(gtb.SchemaName, gtb.TableName);

                    if (tbCols == null) // objeto inválido
                    {
                        continue;
                    }

                    Dictionary <string, GenColumn> dict = new Dictionary <string, GenColumn>(StringComparer.InvariantCultureIgnoreCase);
                    foreach (var col in gtb.Columns)
                    {
                        if (!dict.ContainsKey(col.ColumnName))
                        {
                            dict.Add(col.ColumnName, col);
                        }
                    }

                    foreach (var col in tbCols)
                    {
                        GenColumn gcol;
                        if (dict.TryGetValue(col.ColumnName, out gcol))
                        {
                            dict.Remove(col.ColumnName); // remove as existentes
                            // se existe, mas o banco é required, força required;
                            if (!col.IsNullable)
                            {
                                gcol.IsRequired = true;
                            }

                            // o tipo sempre vem do banco
                            gcol.DataType = col.DataTypeDotNet;
                        }
                        else
                        {
                            gcol              = new GenColumn();
                            gcol.ColumnName   = col.ColumnName;
                            gcol.PropertyName = null;
                            gcol.Description  = null;
                            gcol.IsRequired   = !col.IsNullable;
                            gcol.DataType     = col.DataTypeDotNet;
                            gtb.Columns.Add(gcol);
                        }
                    }

                    // se sobrou no dict, é pq as colunas foram apagadas da table, ou renomedas
                    foreach (var pair in dict)
                    {
                        gtb.Columns.RemoveAll(p => p.ColumnName.EqualsICIC(pair.Key));
                    }

                    grid.Rows.Insert(r);
                    //grid.Rows.SetHeight(r, 40);
                    //grid.Rows.AutoSizeRow(r);

                    SourceGrid.GridRow row = grid.Rows[r];

                    // tags
                    row.AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize | SourceGrid.AutoSizeMode.EnableStretch;
                    row.Tag          = node;
                    gtb.Tag          = tbCols;
                    node.Tag         = row;

                    grid[r, Col.SchemaName] = new SourceGrid.Cells.Cell(gtb.SchemaName);
                    grid[r, Col.TableName]  = new SourceGrid.Cells.Cell(gtb.TableName);

                    SourceGrid.Cells.Editors.EditorBase ed;

                    ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                    ed.EditableMode            = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    grid[r, Col.DataClassName] = new SourceGrid.Cells.Cell(gtb.DataClassName, ed);

                    ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                    ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    grid[r, Col.BusinessClassName] = new SourceGrid.Cells.Cell(gtb.BusinessClassName, ed);

                    // EnumColumnName
                    SourceGrid.Cells.Editors.ComboBox cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                    var cols = (from c in tbCols where c.DataTypeDotNet.ToLower().Contains("string") orderby c.ColumnName select c.ColumnName).ToList();
                    if (!string.IsNullOrWhiteSpace(gtb.EnumColumnName))
                    {
                        if (cols.FirstOrDefault(p => p.ToUpper() == gtb.EnumColumnName) == null)
                        {
                            gtb.EnumColumnName = gtb.EnumColumnId = gtb.EnumName = null;
                        }
                    }
                    else
                    {
                        gtb.EnumColumnName = gtb.EnumColumnId = gtb.EnumName = null;
                    }

                    if (cols.Count > 0)
                    {
                        cols.Insert(0, "");
                        cbEditor.StandardValues = cols;
                        cbEditor.EditableMode   = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    }
                    else
                    {
                        cbEditor.EditableMode = SourceGrid.EditableMode.None;
                    }
                    grid[r, Col.EnumColumnName] = new SourceGrid.Cells.Cell(gtb.EnumColumnName, cbEditor);

                    // EnumColumnId
                    cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                    cols     = (from c in tbCols where numericTypes.ContainsKey(c.DataTypeDotNet.Replace("?", "")) orderby c.ColumnName select c.ColumnName).ToList();
                    if (cols.Count > 0)
                    {
                        cols.Insert(0, "");
                        cbEditor.StandardValues = cols;
                        cbEditor.EditableMode   = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    }
                    else
                    {
                        cbEditor.EditableMode = SourceGrid.EditableMode.None;
                    }
                    grid[r, Col.EnumColumnId] = new SourceGrid.Cells.Cell(gtb.EnumColumnId, cbEditor);

                    // EnumName
                    ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                    ed.EditableMode       = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    grid[r, Col.EnumName] = new SourceGrid.Cells.Cell(gtb.EnumName, ed);

                    // EnumAttributes
                    ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                    ed.EditableMode             = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    grid[r, Col.EnumAttributes] = new SourceGrid.Cells.Cell(gtb.EnumAttributes, ed);

                    // SequenceColumn
                    cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                    cols     = (from c in tbCols where numericTypes.ContainsKey(c.DataTypeDotNet.Replace("?", "")) orderby c.ColumnName select c.ColumnName).ToList();
                    if (cols.Count > 0)
                    {
                        cols.Insert(0, "");
                        cbEditor.StandardValues = cols;
                        cbEditor.EditableMode   = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    }
                    else
                    {
                        cbEditor.EditableMode = SourceGrid.EditableMode.None;
                    }
                    grid[r, Col.SequenceColumn] = new SourceGrid.Cells.Cell(gtb.SequenceColumn, cbEditor);

                    // SequenceName
                    cbEditor = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                    if (sequences.Count > 0)
                    {
                        cols.Insert(0, "");
                        cbEditor.StandardValues = (from c in sequences select c.FullName).ToList();
                        cbEditor.EditableMode   = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    }
                    else
                    {
                        cbEditor.EditableMode = SourceGrid.EditableMode.None;
                    }
                    grid[r, Col.SequenceName] = new SourceGrid.Cells.Cell(gtb.SequenceName, cbEditor);

                    var ed2 = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                    var txt = (SourceGrid.Cells.Editors.TextBox)ed2;
                    txt.Control.Multiline     = true;
                    txt.Control.AcceptsReturn = true;
                    //txt.Control.ScrollBars = ScrollBars.Both;
                    //txt.Control.ImeMode = ImeMode.Disable;

                    ed2.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    //if (gtb.Attributes != null)
                    //{
                    //    gtb.Attributes =  gtb.Attributes.Replace("\r\n", "\n");
                    //    gtb.Attributes = gtb.Attributes.Replace("\n", "\r\n\r\n");
                    //}

                    grid[r, Col.Attributes] = new SourceGrid.Cells.Cell(gtb.Attributes, ed2);

                    //ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                    //ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                    //grid[r, 5] = new SourceGrid.Cells.Cell(gtb.SubDirectory, ed);
                    r++;
                    //string time = tc.ToString();
                }
                catch (Exception ex)
                {
                    //Program.ShowError(ex);
                }
            }

            // remove objetos não mais existentes na base de dados
            var objs = tableViewNode is NodeTables ? file.Parameters.Tables : file.Parameters.Views;

            foreach (var obj in objs.ToList())
            {
                if (!objects.ContainsKey(obj.FullName))
                {
                    objs.Remove(obj);
                }
            }

            grid.Selection.FocusRowEntered += Selection_FocusRowEntered;
            grid.Selection.FocusRowLeaving += Selection_FocusRowLeaving;
            grid.AutoSizeCells();

            string time = tc.ToString();
        }
예제 #16
0
        void ExecuteWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            mnuExecute.Text           = "Execute";
            mnuExecute.ForeColor      = SystemColors.ControlText;
            mnuRun.Enabled            = true;
            mnuSchema.Enabled         = true;
            this.Cursor               = Cursors.Default;
            textEditorControl1.Cursor = Cursors.Default;
            timer.Stop();

            if (e.Cancelled)
            {
                lblCurrentStatus.Text = string.Format("Query cancelled");
            }
            else if (e.Error != null)
            {
                this.Cursor = Cursors.Default;
                Program.logger.ErrorException("Execute", e.Error);
                lblCurrentStatus.Text = "Error: " + e.Error.Message;
                MessageBox.Show("An error occurred executing sql statement data:\n" + e.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (e.Result != null && e.Result is IList <IList <object> > )
            {
                IList <IList <object> > result = (IList <IList <object> >)e.Result;

                grid1.ClipboardMode = SourceGrid.ClipboardMode.All;
                grid1.Rows.Clear();
                grid1.FixedRows    = 1;
                grid1.FixedColumns = 1;
                SourceGrid.Cells.Editors.EditorBase editor = new SourceGrid.Cells.Editors.TextBox(typeof(string));
                editor.EnableEdit = false;

                // Set the column count
                int colCount = result[0].Count;
                grid1.ColumnsCount = colCount + 1; // Extra one for header

                // Write the header
                grid1.Rows.Insert(0);
                grid1[0, 0] = new SourceGrid.Cells.ColumnHeader("");
                for (int c = 0; c < colCount; c++)
                {
                    grid1[0, c + 1] = new SourceGrid.Cells.ColumnHeader(result[0][c]);
                }

                int i = 0;

                // Write the values
                foreach (List <object> row in result.Skip(1))
                {
                    i++;
                    grid1.Rows.Insert(i);
                    grid1[i, 0] = new SourceGrid.Cells.RowHeader(i.ToString());
                    for (int c = 0; c < colCount; c++)
                    {
                        if (row[c] == null)
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell("", typeof(string));
                        }
                        else if (row[c] == typeof(DateTime))
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell(((DateTime)row[c]).ToString("yyyy-MM-dd HH:mm:ss"), typeof(string));
                        }
                        else if (row[c] == typeof(string))
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell(row[c].ToString().Trim(), typeof(string));
                        }
                        else
                        {
                            grid1[i, c + 1] = new SourceGrid.Cells.Cell(row[c], typeof(double));
                        }

                        grid1[i, c + 1].Editor = editor;
                    }
                }

                grid1.AutoSizeCells();
                grid1.Visible         = true;
                lblCurrentStatus.Text = string.Format("Query completed in {0}s", DateTime.Now.Subtract(start).TotalSeconds);
            }
        }
예제 #17
0
        void LoadColumns(SourceGrid.Grid grid, NodeTable node)
        {
            GenTable table = node.Item;

            grid.BorderStyle   = BorderStyle.FixedSingle;
            grid.SelectionMode = SourceGrid.GridSelectionMode.Cell;
            grid.ClipboardMode = SourceGrid.ClipboardMode.All;

            grid.Rows.Clear();
            grid.Columns.Clear();

            grid.ColumnsCount = 7;
            grid.FixedRows    = 0;
            grid.FixedColumns = 2;

            //int r = 0;
            SourceGrid.Cells.Views.Cell categoryView = new SourceGrid.Cells.Views.Cell();
            categoryView.Background    = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.Gainsboro, Color.WhiteSmoke, 0);
            categoryView.ForeColor     = Color.Black;
            categoryView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            categoryView.Border        = DevAge.Drawing.RectangleBorder.NoBorder;
            categoryView.Font          = new Font(Font, FontStyle.Bold);

            //grid.Rows.Insert(r);
            //grid[r, 0] = new SourceGrid.Cells.Cell(title);
            //grid[r, 0].View = categoryView;
            //grid[r, 0].ColumnSpan = grid.ColumnsCount;

            //r++;
            int r = 0;

            grid.Rows.Insert(r);
            grid.FixedRows = 1;
            headerView     = new SourceGrid.Cells.Views.Cell();
            //headerView.Background = new DevAge.Drawing.VisualElements.BackgroundLinearGradient(Color.Gainsboro, Color.WhiteSmoke, 0);
            headerView.ForeColor     = Color.FromKnownColor(KnownColor.Black);
            headerView.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
            headerView.Border        = DevAge.Drawing.RectangleBorder.NoBorder;
            headerView.Font          = new Font(Font, FontStyle.Bold);

            addHeader(grid, 0, "ColumnName", 130);
            addHeader(grid, 1, "PropertyName", 130);
            addHeader(grid, 2, "Title", 250);
            addHeader(grid, 3, "DataType", 100);
            addHeader(grid, 4, "Required", 70);
            addHeader(grid, 5, "Description", 200);
            addHeader(grid, 6, "Attributes", 300);
            //addHeader(grid, 5, "Sub-directory", 150);

            for (int c = 0; c < grid.ColumnsCount; c++)
            {
                grid[r, c].View = categoryView;
            }

            foreach (GenColumn col in table.Columns)
            {
                r++;

                grid.Rows.Insert(r);
                SourceGrid.GridRow row = grid.Rows[r];

                // tags
                row.Tag = node;

                SourceGrid.Cells.Editors.EditorBase ed;

                ed         = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                grid[r, 0] = new SourceGrid.Cells.Cell(col.ColumnName, ed);

                ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                grid[r, 1]      = new SourceGrid.Cells.Cell(col.PropertyName, ed);

                ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                grid[r, 2]      = new SourceGrid.Cells.Cell(col.Title, ed);

                ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                ed.EditableMode = SourceGrid.EditableMode.None;
                grid[r, 3]      = new SourceGrid.Cells.Cell(col.DataType, ed);

                ed = SourceGrid.Cells.Editors.Factory.Create(typeof(bool));
                ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick;
                grid[r, 4]      = new SourceGrid.Cells.Cell(col.IsRequired, ed);

                ed = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                ed.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                grid[r, 5]      = new SourceGrid.Cells.Cell(col.Description, ed);

                var ed2 = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
                var txt = (SourceGrid.Cells.Editors.TextBox)ed2;
                txt.Control.Multiline     = true;
                txt.Control.AcceptsReturn = true;
                ed2.EditableMode          = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.SingleClick | SourceGrid.EditableMode.AnyKey;
                grid[r, 6] = new SourceGrid.Cells.Cell(col.Attributes, ed2);
            }
            grid.AutoSizeCells();

            grid.Selection.FocusRowLeaving += Selection_FocusRowLeavingColumns;
        }
예제 #18
0
        private void frmSampleGrid1_Load(object sender, System.EventArgs e)
        {
            string[] l_CountryList = new string[] { "Italy", "France", "Spain", "UK", "Argentina", "Mexico", "Switzerland", "Brazil", "Germany", "Portugal", "Sweden", "Austria" };

            grid1.RowsCount                    = 1;
            grid1.ColumnsCount                 = 10;
            grid1.FixedRows                    = 1;
            grid1.FixedColumns                 = 1;
            grid1.Selection.SelectionMode      = SourceGrid.GridSelectionMode.Row;
            grid1.AutoStretchColumnsToFitWidth = true;
            grid1.Columns[0].AutoSizeMode      = SourceGrid.AutoSizeMode.None;
            grid1.Columns[0].Width             = 25;

            //Enable Drag and Drop
            grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrag.Cut);
            grid1.GridController.AddController(SourceGrid.Controllers.SelectionDrop.Default);


            #region Create Grid Style, Views and Controllers
            //Views
            mView_Default = new SourceGrid.Cells.Views.Cell();

            mView_Price = new SourceGrid.Cells.Views.Cell();
            mView_Price.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleRight;

            mView_CheckBox = new SourceGrid.Cells.Views.CheckBox();

            mView_Link = new SourceGrid.Cells.Views.Link();

            mView_RowHeader    = new SourceGrid.Cells.Views.RowHeader();
            mView_ColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            mView_Header       = new SourceGrid.Cells.Views.Header();

            //Style
            SourceGrid.Styles.StyleGrid style = new SourceGrid.Styles.StyleGrid();
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(null, null, typeof(string), mView_Default));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(null, null, typeof(DateTime), mView_Default));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(null, null, typeof(int), mView_Default));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(null, null, typeof(Boolean), mView_CheckBox));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(null, null, typeof(double), mView_Price));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(typeof(SourceGrid.Cells.Link), null, null, mView_Link));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(typeof(SourceGrid.Cells.Header), null, null, mView_Header));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(typeof(SourceGrid.Cells.ColumnHeader), null, null, mView_ColumnHeader));
            style.StyleCells.Add(new SourceGrid.Styles.StyleCell(typeof(SourceGrid.Cells.RowHeader), null, null, mView_RowHeader));
            grid1.StyleGrid = style;

            mController_Link           = new SourceGrid.Cells.Controllers.Button();
            mController_Link.Executed += new EventHandler(mController_Link_Click);
            #endregion

            #region Create Header Row and Editor
            SourceGrid.Cells.Header l_00Header = new SourceGrid.Cells.Header(null);
            grid1[0, 0] = l_00Header;

            mEditor_Id = SourceGrid.Cells.Editors.Factory.Create(typeof(int));
            mEditor_Id.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 1]             = new SourceGrid.Cells.ColumnHeader("ID (int)");

            mEditor_Name = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
            mEditor_Name.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 2] = new SourceGrid.Cells.ColumnHeader("NAME (string)");

            mEditor_Address = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
            mEditor_Address.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 3] = new SourceGrid.Cells.ColumnHeader("ADDRESS (string)");

            mEditor_City = SourceGrid.Cells.Editors.Factory.Create(typeof(string));
            mEditor_City.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 4] = new SourceGrid.Cells.ColumnHeader("CITY (string)");

            mEditor_BirthDay = SourceGrid.Cells.Editors.Factory.Create(typeof(DateTime));
            mEditor_BirthDay.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 5] = new SourceGrid.Cells.ColumnHeader("BIRTHDATE (DateTime)");

            mEditor_Country = new SourceGrid.Cells.Editors.ComboBox(typeof(string), l_CountryList, false);
            mEditor_Country.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 6] = new SourceGrid.Cells.ColumnHeader("COUNTRY (string + combobox)");

            mEditor_Price = new SourceGrid.Cells.Editors.TextBoxCurrency(typeof(double));
            mEditor_Price.EditableMode = SourceGrid.EditableMode.Focus | SourceGrid.EditableMode.AnyKey | SourceGrid.EditableMode.SingleClick;
            grid1[0, 7] = new SourceGrid.Cells.ColumnHeader("$ PRICE (double)");

            grid1[0, 8] = new SourceGrid.Cells.ColumnHeader("Selected");

            grid1[0, 9] = new SourceGrid.Cells.ColumnHeader("WebSite");
            #endregion

            //Read Data From xml
            System.IO.StreamReader reader = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsSample.GridSamples.SampleData.xml"));
            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.LoadXml(reader.ReadToEnd());
            reader.Close();
            System.Xml.XmlNodeList rows = xmlDoc.SelectNodes("//row");
            grid1.RowsCount = rows.Count + 1;
            int rowsCount = 1;
            foreach (System.Xml.XmlNode l_Node in rows)
            {
                #region Pupulate RowsCount
                grid1[rowsCount, 0] = new SourceGrid.Cells.RowHeader(null);

                grid1[rowsCount, 1] = new SourceGrid.Cells.Cell(rowsCount, mEditor_Id);

                grid1[rowsCount, 2] = new SourceGrid.Cells.Cell(l_Node.Attributes["ContactName"].InnerText, mEditor_Name);

                grid1[rowsCount, 3] = new SourceGrid.Cells.Cell(l_Node.Attributes["Address"].InnerText, mEditor_Address);

                grid1[rowsCount, 4] = new SourceGrid.Cells.Cell(l_Node.Attributes["City"].InnerText, mEditor_City);

                grid1[rowsCount, 5] = new SourceGrid.Cells.Cell(DateTime.Today, mEditor_BirthDay);

                grid1[rowsCount, 6] = new SourceGrid.Cells.Cell(l_Node.Attributes["Country"].InnerText, mEditor_Country);

                grid1[rowsCount, 7] = new SourceGrid.Cells.Cell(25.0, mEditor_Price);

                grid1[rowsCount, 8] = new SourceGrid.Cells.CheckBox(null, false);

                grid1[rowsCount, 9] = new SourceGrid.Cells.Link(l_Node.Attributes["website"].InnerText);
                grid1[rowsCount, 9].AddController(mController_Link);
                #endregion

                rowsCount++;
            }

            grid1.AutoSizeCells();
        }
예제 #19
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //Border
            DevAge.Drawing.Border          border     = new DevAge.Drawing.Border(Color.DarkKhaki, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            //Views Odd
            SourceGrid.Cells.Views.Cell viewOddNormal = new SourceGrid.Cells.Views.Cell();
            viewOddNormal.BackColor = Color.Khaki;
            viewOddNormal.Border    = cellBorder;
            SourceGrid.Cells.Views.CheckBox viewOddCheckBox = new SourceGrid.Cells.Views.CheckBox();
            viewOddCheckBox.BackColor = Color.Khaki;
            viewOddCheckBox.Border    = cellBorder;

            //Views Even
            SourceGrid.Cells.Views.Cell viewEvenNormal = new SourceGrid.Cells.Views.Cell(viewOddNormal);
            viewEvenNormal.BackColor = Color.DarkKhaki;
            SourceGrid.Cells.Views.CheckBox viewEvenCheckBox = new SourceGrid.Cells.Views.CheckBox(viewOddCheckBox);
            viewEvenCheckBox.BackColor = Color.DarkKhaki;

            //ColumnHeader view
            SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            viewColumnHeader.ForeColor = Color.White;
            viewColumnHeader.Font      = new Font("Comic Sans MS", 10, FontStyle.Underline);

            DevAge.Drawing.VisualElements.ColumnHeader backgroundColHeader = new DevAge.Drawing.VisualElements.ColumnHeader();
            backgroundColHeader.BackColor = Color.Maroon;
            viewColumnHeader.Background   = backgroundColHeader;

            //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;
            columnHeader.AutomaticSortEnabled = false;
            grid1[0, 0] = columnHeader;

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

            columnHeader      = new SourceGrid.Cells.ColumnHeader("CheckBox");
            columnHeader.View = viewColumnHeader;
            columnHeader.AutomaticSortEnabled = false;
            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);

                if (Math.IEEERemainder(r, 2) == 0)
                {
                    grid1[r, 0].View = viewOddNormal;
                    grid1[r, 1].View = viewOddNormal;
                    grid1[r, 2].View = viewOddCheckBox;
                }
                else
                {
                    grid1[r, 0].View = viewEvenNormal;
                    grid1[r, 1].View = viewEvenNormal;
                    grid1[r, 2].View = viewEvenCheckBox;
                }
            }

            grid1.AutoSizeCells();
        }
예제 #20
0
        private void frmSample14_Load(object sender, System.EventArgs e)
        {
            grid1.Redim(20, 10);
            grid1.FixedRows = 2;

            //1 Header Row
            grid1[0, 0]            = new MyHeader("3 Column Header");
            grid1[0, 0].ColumnSpan = 3;
            grid1[0, 3]            = new MyHeader("5 Column Header");
            grid1[0, 3].ColumnSpan = 5;
            grid1[0, 8]            = new MyHeader("1 Column Header");
            grid1[0, 9]            = new MyHeader("1 Column Header");

            //2 Header Row
            grid1[1, 0] = new MyHeader("1");
            grid1[1, 1] = new MyHeader("2");
            grid1[1, 2] = new MyHeader("3");
            grid1[1, 3] = new MyHeader("4");
            grid1[1, 4] = new MyHeader("5");
            grid1[1, 5] = new MyHeader("6");
            grid1[1, 6] = new MyHeader("7");
            grid1[1, 7] = new MyHeader("8");
            grid1[1, 8] = new MyHeader("9");
            grid1[1, 9] = new MyHeader("10");

            SourceGrid.Cells.Views.Cell viewImage = new SourceGrid.Cells.Views.Cell();

            SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
            clickEvent.Click += new EventHandler(clickEvent_Click);

            for (int r = 2; r < grid1.RowsCount; r = r + 2)
            {
                grid1[r, 0]            = new SourceGrid.Cells.Cell(r.ToString(), typeof(string));
                grid1[r, 0].ColumnSpan = 2;

                grid1[r + 1, 0]            = new SourceGrid.Cells.Cell(DateTime.Today.AddDays(r), typeof(DateTime));
                grid1[r + 1, 0].ColumnSpan = 2;

                grid1[r, 2]            = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false);
                grid1[r, 2].ColumnSpan = 2;
                grid1[r, 2].RowSpan    = 2;

                grid1[r, 4]            = new SourceGrid.Cells.Link("Link Column/Row Span");
                grid1[r, 4].ColumnSpan = 2;
                grid1[r, 4].RowSpan    = 2;
                grid1[r, 4].AddController(clickEvent);

                grid1[r, 6]            = new SourceGrid.Cells.Button("Button Column/Row Span");
                grid1[r, 6].ColumnSpan = 2;
                grid1[r, 6].RowSpan    = 2;
                grid1[r, 6].AddController(clickEvent);

                grid1[r, 8]            = new SourceGrid.Cells.Cell("Image Column/Row Span");
                grid1[r, 8].View       = viewImage;
                grid1[r, 8].Image      = Properties.Resources.FACE02.ToBitmap();
                grid1[r, 8].ColumnSpan = 2;
                grid1[r, 8].RowSpan    = 2;
            }

            grid1.AutoSizeCells();
        }