KB Article A2841
Visible to All Users

How to change the row error icon which is displayed within a row indicator

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 Basic
Private 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

Comments (2)
SK SK
Sharmila Kalaimani 1 9 years ago

    Hi .Can I achieve the same functionality in WPF tableview

    DevExpress Support Team 9 years ago

      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.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.