Change datagridview combobox cell style on form load?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Beany
    New Member
    • Nov 2006
    • 173

    Change datagridview combobox cell style on form load?

    Morning,

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

    Code:
    Private Sub DataGridView1_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
    
            If e.RowIndex <> -1 AndAlso e.ColumnIndex = Column1.Index Then
                Dim cell As DataGridViewComboBoxCell = DataGridView1(e.ColumnIndex, e.RowIndex)
                Dim retrievedValue As Boolean = cell.Value 'DataGridView1(e.ColumnIndex, e.RowIndex).Value
    
                If retrievedValue = True Then
                    cell.Style.BackColor = Color.Green
                Else
                    If retrievedValue = False Then
                        cell.Style.BackColor = Color.Red
                    End If
                End If
            End If
    
    
        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
  • Beany
    New Member
    • Nov 2006
    • 173

    #2
    anyone? Need help with this...

    Comment

    Working...