VGridControlBase.InvalidateRecord(Int32) Method
Invalidates the specified record.
Namespace: DevExpress.XtraVerticalGrid
Assembly: DevExpress.XtraVerticalGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
record |
Int32 | An integer value that identifies the record to be invalidated. |
#Remarks
The InvalidateRecord method can be useful when cells are custom painted and the cells that reside within a particular record need to be redrawn due to custom changes that don’t lead to automatic repainting. To repaint the whole row use the VGridControlBase.InvalidateRow method.
#Example
The following sample code custom paints records that contain information about shops that require a Visa credit card for payment. The VGridControlBase.CustomDrawRowValueCell event is handled to custom paint the record. The VGridControlBase.CellValueChanged event is handled to call the VGridControlBase.InvalidateRecord
method to force the vertical grid control to update the record containing the data cell which value has been changed to Visa.
The image below shows a VGridControl‘s look & feel before and after execution of the sample code and changing the payment method.
using System.Drawing;
using System.Drawing.Drawing2D;
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
using DevExpress.XtraVerticalGrid.Events;
// ...
private void vGridControl1_CustomDrawRowValueCell(object sender,
CustomDrawRowValueCellEventArgs e) {
if(e.Row == rowPicture) return;
VGridControl grid = sender as VGridControl;
// determining the brush used to fill data cell's background
using(var backBrush = new SolidBrush(Color.FromArgb(253, 189, 64))) {
if(grid.GetCellValue(rowPaymentType, e.RecordIndex).ToString() == "Visa") {
// filling the background
e.Cache.FillRectangle(backBrush, e.Bounds);
// painting 3D border
ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
// painting the text displaying within the data cell
e.Cache.DrawString(e.CellText, e.Appearance.Font, Brushes.Black,
e.Bounds, e.Appearance.GetStringFormat());
e.Handled = true;
}
}
}
private void vGridControl1_CellValueChanged(object sender, CellValueChangedEventArgs e) {
VGridControl grid = sender as VGridControl;
if (e.Row == rowPaymentType)
grid.InvalidateRecord(grid.FocusedRecord);
}