Description:
When I validate a row and set the DataRow.Error to an error message, your grid control displays a red icon to the left of the row. Is there anyway I can make that icon bigger?
Answer:
Yes, you can achieve this task by handling the CustomDrawRowIndicator event. Within this event you can draw any Icon within the indicator:
C#private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e) {
if (e.Info.IsRowIndicator){
DataRow row = gridView1.GetDataRow(e.RowHandle);
if (row != null && row.RowError != String.Empty) {
e.Info.ImageIndex = -1;
e.Painter.DrawObject(e.Info);
Rectangle r = e.Bounds;
r.Inflate(-1, -1);
int x = r.X + (r.Width - imageList1.ImageSize.Width) / 2;
int y = r.Y + (r.Height - imageList1.ImageSize.Height) / 2;
e.Cache.DrawImageUnscaled(imageList1.Images[0], x, y);
e.Handled = true;
}
}
}
Visual BasicPrivate Sub GridView1_CustomDrawRowIndicator(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs) Handles GridView1.CustomDrawRowIndicator
If e.Info.IsRowIndicator Then
Dim row As DataRow = GridView1.GetDataRow(e.RowHandle)
If Not IsNothing(row) And row.RowError <> String.Empty Then
e.Info.ImageIndex = -1
e.Painter.DrawObject(e.Info)
Dim r As Rectangle = e.Bounds
r.Inflate(-1, -1)
Dim x As Integer = r.X + (r.Width - imageList1.ImageSize.Width) / 2
Dim y As Integer = r.Y + (r.Height - ImageList1.ImageSize.Height) / 2
e.Cache.DrawImageUnscaled(ImageList1.Images(0), x, y)
e.Handled = True
End If
End If
End Sub
Additionally, we suggest that you review the GridCustomDraw tutorial which is shipped with the XtraGrid installation.
See Also:
How to display a custom error icon when an end-user enters invalid data into an editor
Hi .Can I achieve the same functionality in WPF tableview
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T337522: WPF tableview - How to change the row error icon which is displayed within a row indicator. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.