By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,041 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,041 IT Pros & Developers. It's quick & easy.

Change datagridview combobox cell style on form load?

P: 173

at the moment i can change the datagridview combobox cell style using the cellvaluechanged event handler using the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
  3.         If e.RowIndex <> -1 AndAlso e.ColumnIndex = Column1.Index Then
  4.             Dim cell As DataGridViewComboBoxCell = DataGridView1(e.ColumnIndex, e.RowIndex)
  5.             Dim retrievedValue As Boolean = cell.Value 'DataGridView1(e.ColumnIndex, e.RowIndex).Value
  7.             If retrievedValue = True Then
  8.                 cell.Style.BackColor = Color.Green
  9.             Else
  10.                 If retrievedValue = False Then
  11.                     cell.Style.BackColor = Color.Red
  12.                 End If
  13.             End If
  14.         End If
  17.     End Sub
how can i amend this code so that i can do the same but on form load? so when the form loads, if combobox value is paid show the backcolor as 'green' and if unpaid then show backcolor as 'red'?

many thanks
Apr 23 '12 #1
Share this Question
Share on Google+
1 Reply

P: 173
anyone? Need help with this...
May 3 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.