I've researched the heck out of this one and cannot find a solution using the DataGridView control.
Using VS2005 I'm trying to display one of two Icons in a datagridview control column based on the boolean value of the columns row data.
The data source is based on a Person table with a Name and ActiveUser status field. If the ActiveUser field is true I want to display IconA, otherwise I want to display IconB. I've created a procedure to format the grid which I'm calling right after populating the datagridview control...
Can someone explain to me how I display a different Icon in the second column based on the value of the ActiveUser? In essence I want the grid to display the Persons name in the first column and the Icon in the second column.
Using VS2005 I'm trying to display one of two Icons in a datagridview control column based on the boolean value of the columns row data.
The data source is based on a Person table with a Name and ActiveUser status field. If the ActiveUser field is true I want to display IconA, otherwise I want to display IconB. I've created a procedure to format the grid which I'm calling right after populating the datagridview control...
Code:
Private Sub FormatDataGridView()
Dim objCellStyle As New DataGridViewCellStyle
With objCellStyle
.Alignment = DataGridViewContentAlignment.MiddleLeft
.Font = New Font("Courier New", 10, FontStyle.Regular)
End With
Me.dgvPersons.Columns(0).DefaultCellStyle = objCellStyle
'--- Column(1) is the ActiveUser, a boolean value.
'--- I want to display IconA or IconB based on it's value.
'--- The Icons are stored in My.Resources as either icoActive or icoInactive.
End Sub