GrapeCity MultiRow Windows Forms Documentation
BackColor and ForeColor

You can set three types of backcolors depending on the status of the cells.

Deselected Color

The cell colors, when they are not selected, can be set with the CellStyle.BackColor and CellStyle.ForeColor properties.

Using Code

This example sets the forecolor and backcolor.

[VB]

GcMultiRow1.Rows(0).Cells(0).Style.BackColor = Color.LightBlue
GcMultiRow1.Rows(0).Cells(0).Style.ForeColor = Color.Blue

[CS]

gcMultiRow1.Rows[0].Cells[0].Style.BackColor = Color.LightBlue;
gcMultiRow1.Rows[0].Cells[0].Style.ForeColor = Color.Blue;

Selected Color

The selected cell color can be set with the CellStyle.SelectionBackColor and CellStyle.SelectionForeColor properties.

Using Code

This example sets the SelectionBackColor and SelectionForeColor properties.

[VB]

GcMultiRow1.DefaultCellStyle.SelectionBackColor = Color.Red
GcMultiRow1.DefaultCellStyle.SelectionForeColor = Color.White

[CS]

gcMultiRow1.DefaultCellStyle.SelectionBackColor = Color.Red;
gcMultiRow1.DefaultCellStyle.SelectionForeColor = Color.White;

Edit Mode Color

The color of the cell when it is in edit mode can be set using the CellStyle.EditingBackColor and CellStyle.EditingForeColor properties.

Using Code

This example sets the EditingBackColor and EditingForeColor properties.

[VB]

GcMultiRow1.DefaultCellStyle.EditingBackColor = Color.Yellow
GcMultiRow1.DefaultCellStyle.EditingForeColor = Color.Green

[CS]

gcMultiRow1.DefaultCellStyle.EditingBackColor = Color.Yellow;
gcMultiRow1.DefaultCellStyle.EditingForeColor = Color.Green;

Disabled Color

The disabled cell color can be set with the CellStyle.DisabledBackColor and CellStyle.DisabledForeColor properties.

Using Code

This example sets the DisabledBackColor and DisabledForeColor properties.

[VB]

GcMultiRow1.DefaultCellStyle.DisabledBackColor = SystemColors.Control
GcMultiRow1.DefaultCellStyle.DisabledForeColor = SystemColors.ControlLight

[CS]

gcMultiRow1.DefaultCellStyle.DisabledBackColor = SystemColors.Control;
gcMultiRow1.DefaultCellStyle.DisabledForeColor = SystemColors.ControlLight;

Background Color and Visual Style

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.

Using Code

This example sets the style.

[VB]

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})

[CS]

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 });
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options