Exemple #1
0
        //set Highlight to the current row & column
        void TableControl_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
        {
            GridCurrentCell cc   = gridGroupingControl1.TableControl.CurrentCell;
            GridControlBase grid = this.gridGroupingControl1.TableControl.CurrentCell.Grid;

            if (radioButton3.Checked)
            {
                // Highlight the current row with SystemColors.Highlight and bold font
                if (e.RowIndex > grid.Model.Cols.HeaderCount + 1 && e.ColIndex > grid.Model.Rows.HeaderCount &&
                    cc.HasCurrentCellAt(e.RowIndex))
                {
                    e.Style.Interior  = new BrushInfo(SystemColors.Highlight);
                    e.Style.TextColor = SystemColors.HighlightText;
                    e.Style.Font.Bold = true;
                }
            }
            else if (radioButton2.Checked)
            {
                // Highlight the current cell with SystemColors.Highlight and bold font
                if (e.RowIndex > grid.Model.Cols.HeaderCount + 1 && e.ColIndex > grid.Model.Rows.HeaderCount &&
                    cc.HasCurrentCellAt(e.RowIndex, e.ColIndex))
                {
                    e.Style.Interior  = new BrushInfo(SystemColors.Highlight);
                    e.Style.TextColor = SystemColors.HighlightText;
                    e.Style.Font.Bold = true;
                }
            }
            else if (radioButton4.Checked)
            {
                // Highlight the current column with SystemColors.Highlight and bold font
                if (e.RowIndex > grid.Model.Cols.HeaderCount + 1 && e.ColIndex > grid.Model.Rows.HeaderCount &&
                    cc.ColIndex == e.ColIndex)
                {
                    e.Style.Interior  = new BrushInfo(SystemColors.Highlight);
                    e.Style.TextColor = SystemColors.HighlightText;
                    e.Style.Font.Bold = true;
                }
            }
            else if (radioButton5.Checked)
            {
                // Highlight the current row & col with SystemColors.Highlight and bold font
                if (e.RowIndex > grid.Model.Cols.HeaderCount + 1 && e.ColIndex > grid.Model.Rows.HeaderCount &&
                    (cc.RowIndex == e.RowIndex || cc.ColIndex == e.ColIndex))
                {
                    e.Style.Interior  = new BrushInfo(SystemColors.Highlight);
                    e.Style.TextColor = SystemColors.HighlightText;
                    e.Style.Font.Bold = true;
                }
            }
        }
Exemple #2
0
        void TableControl_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
        {
            GridTableCellStyleInfo         style = (GridTableCellStyleInfo)e.Style;
            GridTableCellStyleInfoIdentity id    = style.TableCellIdentity;

            // Cell identity contains information about the cell (element, column etc.)

            // Check if this is a indent cell
            if (id.TableCellType == GridTableCellType.GroupIndentCell)
            {
                Group group = id.DisplayElement.ParentGroup;

                // Check if this is the indent of a Categories_CategoryName group.
                if (group != null && group.CategoryColumns.Count > 0 && group.CategoryColumns[0].Name == Customers_ContactName)
                {
                    // And if the group is not empty ...
                    if (group.Records.Count > 0)
                    {
                        // Get the category name from the first record
                        Record r     = group.Records[0];
                        object value = r.GetValue(Customers_ContactName);

                        // Should be a string
                        string empName = value as string;

                        // Assign the name to the CellValue of the Indent cell and also adjust the font, color and other style settings.
                        if (empName != null)
                        {
                            style.Interior            = new BrushInfo(GradientStyle.Vertical, Color.FromArgb(219, 226, 242), Color.FromArgb(255, 187, 111));
                            style.CellValue           = empName;
                            style.CellType            = "Static";
                            style.HorizontalAlignment = GridHorizontalAlignment.Center;
                            style.VerticalAlignment   = GridVerticalAlignment.Middle;
                            style.Trimming            = StringTrimming.EllipsisCharacter;
                            style.Font.Bold           = true;
                            style.Font.Italic         = true;
                            style.Font.Orientation    = 270;
                        }
                    }
                }
            }
            if (e.Style.CellType.ToString() == "Image")
            {
                e.Style.ImageSizeMode = GridImageSizeMode.CenterImage;
            }
        }
Exemple #3
0
 /// <summary>
 /// Set the Backgrond color
 /// </summary>
 void GridGroupDropArea_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
 {
     e.Style.BackColor = Color.FromArgb(255, 203, 146);
 }