Back to Devexpress

VGridControlBase.RecordCellStyle Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-9fd991d1.md

latest4.6 KB
Original Source

VGridControlBase.RecordCellStyle Event

Enables the appearance settings of individual cells to be changed.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

csharp
public event GetCustomRowCellStyleEventHandler RecordCellStyle
vb
Public Event RecordCellStyle As GetCustomRowCellStyleEventHandler

Event Data

The RecordCellStyle event's data class is GetCustomRowCellStyleEventArgs. The following properties provide information specific to this event:

PropertyDescription
AppearanceGets the appearance settings used to paint the cell currently being processed.
CellIndexGets the processed cell’s index. Inherited from RowCellEventArgs.
RecordIndexGets the index of the record containing the processed cell. Inherited from RowCellEventArgs.
RowGets the processed row. Inherited from RowEventArgs.

Remarks

The RecordCellStyle event is raised for individual cells before they need to be repainted. The referenced cell can be identified using the event parameter’s RowEventArgs.Row, RowCellEventArgs.RecordIndex and RowCellEventArgs.CellIndex properties. To customize the cell’s appearance settings use the GetCustomRowCellStyleEventArgs.Appearance property.

Individual cells can also be custom painted. Handle the VGridControlBase.CustomDrawRowValueCell event for this purpose.

Important

Do not change cell values, modify the control’s layout, or change the control’s object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.

Example

The following example handles the VGridControlBase.RecordCellStyle event to modify the appearance of the “Price” row’s cells whose values are greater than 30,000.

csharp
using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_RecordCellStyle(object sender, GetCustomRowCellStyleEventArgs e) {
   if(e.Row != rowPrice) return;
   if(Convert.ToInt32(vGridControl1.GetCellValue(e.Row, e.RecordIndex)) > 30000) {
      e.Appearance.BackColor = Color.Yellow;
      e.Appearance.ForeColor = Color.Black;
      e.Appearance.FontStyleDelta = FontStyle.Bold;
   }
}
vb
Imports DevExpress.XtraVerticalGrid.Events

Private Sub VGridControl1_RecordCellStyle(ByVal sender As Object, _
ByVal e As GetCustomRowCellStyleEventArgs) Handles VGridControl1.RecordCellStyle
    If e.Row <> rowPrice Then Exit Sub
    If Convert.ToInt32(VGridControl1.GetCellValue(e.Row, e.RecordIndex)) > 30000 Then
        e.Appearance.BackColor = Color.Yellow
        e.Appearance.ForeColor = Color.Black
        e.Appearance.FontStyleDelta = FontStyle.Bold
    End If
End Sub

See Also

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace