MultiRow Windows Forms > Developer's Guide > Using MultiRow > Cell Styles > BackColor and ForeColor |
You can set three types of backcolors depending on the status of the cells.
The cell colors, when they are not selected, can be set with the CellStyle.BackColor and CellStyle.ForeColor properties.
This example sets the forecolor and backcolor.
GcMultiRow1.Rows(0).Cells(0).Style.BackColor = Color.LightBlue GcMultiRow1.Rows(0).Cells(0).Style.ForeColor = Color.Blue |
gcMultiRow1.Rows[0].Cells[0].Style.BackColor = Color.LightBlue; gcMultiRow1.Rows[0].Cells[0].Style.ForeColor = Color.Blue; |
The selected cell color can be set with the CellStyle.SelectionBackColor and CellStyle.SelectionForeColor properties.
This example sets the SelectionBackColor and SelectionForeColor properties.
GcMultiRow1.DefaultCellStyle.SelectionBackColor = Color.Red GcMultiRow1.DefaultCellStyle.SelectionForeColor = Color.White |
gcMultiRow1.DefaultCellStyle.SelectionBackColor = Color.Red; gcMultiRow1.DefaultCellStyle.SelectionForeColor = Color.White; |
The color of the cell when it is in edit mode can be set using the CellStyle.EditingBackColor and CellStyle.EditingForeColor properties.
This example sets the EditingBackColor and EditingForeColor properties.
GcMultiRow1.DefaultCellStyle.EditingBackColor = Color.Yellow GcMultiRow1.DefaultCellStyle.EditingForeColor = Color.Green |
gcMultiRow1.DefaultCellStyle.EditingBackColor = Color.Yellow; gcMultiRow1.DefaultCellStyle.EditingForeColor = Color.Green; |
The disabled cell color can be set with the CellStyle.DisabledBackColor and CellStyle.DisabledForeColor properties.
This example sets the DisabledBackColor and DisabledForeColor properties.
GcMultiRow1.DefaultCellStyle.DisabledBackColor = SystemColors.Control GcMultiRow1.DefaultCellStyle.DisabledForeColor = SystemColors.ControlLight |
gcMultiRow1.DefaultCellStyle.DisabledBackColor = SystemColors.Control; gcMultiRow1.DefaultCellStyle.DisabledForeColor = SystemColors.ControlLight; |
When the Windows Visual Style is active for the cells, the backcolor is not shown for the button or the headers. To enable the backcolor when the visual style has been applied, you need to set the ButtonCell.FlatStyle property (ButtonCellBase.FlatStyle property) to Standard and the ButtonCell.UseVisualStyleBackColor property (ButtonCellBase.UseVisualStyleBackColor property) to False.
This example sets the style.
Imports GrapeCity.Win.MultiRow Dim buttonCell As New ButtonCell() buttonCell.FlatStyle = FlatStyle.Standard buttonCell.UseVisualStyleBackColor = False buttonCell.Style.BackColor = Color.Blue buttonCell.Value = "buttonCell" GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {buttonCell}) |
using GrapeCity.Win.MultiRow; ButtonCell buttonCell = new ButtonCell(); buttonCell.FlatStyle = FlatStyle.Standard; buttonCell.UseVisualStyleBackColor = false; buttonCell.Style.BackColor = Color.Blue; buttonCell.Value = "buttonCell"; gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { buttonCell }); |