Hi,
This is my first post in here, I will describe my situation. I would like to change the color of a row based on a boolean value. So what I did was, I used a class called DataGridColoredTextBoxColumn which extends DataGridTextBoxColumn. I have a paint method there which is overriden.

In my code, when the control is being loaded:
VB Code:
  1. Try
  2.             If designmode Then
  3.                 Return
  4.             End If
  5.             AddHandler MainForm.Data.Items.RowChanged, AddressOf ItemRowChanged
  6.             AddHandler MainForm.Data.Items.RowChanging, AddressOf RowChanging
  7.             AddHandler MainForm.Data.Items.RowDeleted, AddressOf RowDeleted
  8.             AddHandler MainForm.Data.Items.RowDeleting, AddressOf RowDeleting
  9.             AddHandler MainForm.Data.Items.ColumnChanged, AddressOf ColumnChanged
  10.             Dim i As Integer = 0
  11.             For Each c As DataColumn In MainForm.Data.Items.Columns
  12.                 ct = New DataGridColoredTextBoxColumn
  13.                 ct.MappingName = c.ColumnName
  14.                 ct.HeaderText = c.ColumnName
  15.                 ct.NullText = ""
  16.                 Select Case c.ColumnName.Trim
  17.  
  18.                     Case "PO No."
  19.                         ct.HeaderText = "PO#"
  20.                         ct.Width = 30
  21.                     Case "Description"
  22.                         ct.HeaderText = "Item Code - Description"
  23.                        ct.Width = 280
  24. '               ... for all columns
  25.                 End Select
  26.                 Try
  27.                     dg.TableStyles(0).GridColumnStyles.Add(ct)
  28.                     If ct.MappingName = "Description" Then
  29.                         ct = New DataGridTextBoxColumn
  30.                         ct.MappingName = "Item Code"
  31.                         ct.HeaderText = "Alpha Code"
  32.                         ct.NullText = ""
  33.                         ct.Width = 100
  34.                         dg.TableStyles(0).GridColumnStyles.Add(ct)
  35.                     End If
  36.                 Catch ex As Exception
  37.                 End Try
  38.                 i += 1
  39. DoNext:
  40.             Next
  41.             dg.DataSource = MainForm.Data
  42.             dg.DataMember = "Items"
  43.          Catch ex As Exception
  44.             PromptMessage(ex.Message, "Error", FrmMessage.ButtonModes.OK, FrmMessage.MessageTypes.ErrorType, ex)
  45.         End Try
I use a listbox which is added to a column of a textbox to add a new row...
The problem with this code is that paint method is called when I add a new row, but I would really like to call it after the row is added. Currently the paint method is being called as soon as I click on the list box which will add a a new row. untill a row is added I cannot retrieve the boolean value which will set the row's color.
Hope that makes sense.
thanks...