title: XtraGrid: Show custom Row Indicator icon
body: <p>How to show custom row indicator icon in DevExpress <strong>XtraGrid</strong> control?</p>
  
  <p><a href="https://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsGridGridView_CustomDrawRowIndicatortopic" rel="nofollow noreferrer">This example</a> demonstrate showing text in RowIndicator column. But I want to show custom images/icons from Resources based on some conditions.</p>
  
  <p>And in <a href="https://www.devexpress.com/Support/Center/Question/Details/A2841" rel="nofollow noreferrer">this example</a>, the error icon is shown.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Private cObj_ImageList As ImageList
  cObj_ImageList = New ImageList()
  cObj_ImageList.Images.Add(My.Resources.lock_red)
  cObj_ImageList.Images.Add(My.Resources.unlock_blue)
  
  Private Sub GridView_CustomDrawRowIndicator(sender As Object, e As RowIndicatorCustomDrawEventArgs)
  
      If e.Info.IsRowIndicator And e.RowHandle &gt;= 0 Then
          Try
              For Each lObj_ChngdRow As ChangedRow In cObj_Lst_ChngdRows
                  If lObj_ChngdRow.CRRowHandle = e.RowHandle And lObj_ChngdRow.IsEditable Then
  
                      'e.Graphics.DrawIcon(cObj_RowStateUnlock, 0, 0)
                      'e.Graphics.DrawImageUnscaled(My.Resources.unlock_blue, 0, 0)
  
                      e.Info.ImageIndex = -1
  
                      e.Painter.DrawObject(e.Info)
  
                      Dim rec As Rectangle = e.Bounds
  
                      rec.Inflate(-1, -1)
  
                      Dim x1 As Integer = rec.X + (rec.Width - cObj_ImageList.ImageSize.Width) / 2
  
  
                      Dim y1 As Integer = rec.Y + (rec.Height - cObj_ImageList.ImageSize.Height) / 2
  
                      e.Graphics.DrawImageUnscaled(cObj_ImageList.Images(1), x1, y1)
  
                      e.Handled = True
  
                  End If
              Next
          Catch ex As Exception
  
          End Try
      End If
  
  End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/sSE6n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sSE6n.png" alt="enter image description here"></a>
  This shows icon for one row only. I want to show for all rows. But when a button <strong>Checkout</strong> is clicked, I want to change this icon.</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>As nempoBu4 explained, I have modified my code to rather more simpler:</p>
  
  <pre><code>Private Sub GridView_CustomDrawRowIndicator(sender As Object, e As RowIndicatorCustomDrawEventArgs)
  
      Try
          If e.Info.IsRowIndicator And e.RowHandle &gt;= 0 Then
  
              e.Handled = True
  
              e.Graphics.DrawImageUnscaled(cObj_ImageList.Images(0), e.Bounds.X, e.Bounds.Y)
  
              Dim lObj_ChngdRow = cObj_Lst_ChngdRows.Find(Function(item) item.CRRowHandle = e.RowHandle AndAlso item.IsEditable)
  
              If Not lObj_ChngdRow Is Nothing Then
  
                  e.Graphics.DrawImageUnscaled(cObj_ImageList.Images(1), e.Bounds.X, e.Bounds.Y)
  
              End If
  
          End If
      Catch ex As Exception
  
      End Try
  
  End Sub
  </code></pre>
  
  <p>See the attached Screenshot. </p>
  
  <p><a href="https://i.stack.imgur.com/LBkRo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LBkRo.png" alt="enter image description here"></a></p>
  
  <p>Red and Blue icons are on top of each others. I think I have to clear the ImageList and then add them again.</p>