I have datagridview which display 3 columns. i would like to show icon in each rows with different by if column 3 = "OFFLINE" then the icon offline show else online show. the above is my code but not working. it is creating other column. please help me.
Chantra.
Public Sub _CreatePublishersGraphicsColumn()
Dim _IconColumn As New DataGridViewImageColumn()
Dim _IconColumn1 As New DataGridViewImageColumn()
With _IconColumn
.Image = frmAddCard.ImageList1.Images.Item(3)
.Name = "OFFLINE"
.Width = 20
.ReadOnly = True
.HeaderText = ""
End With
With _IconColumn1
.Image = frmAddCard.ImageList1.Images.Item(0)
.Name = "ONLINE"
.Width = 20
.ReadOnly = True
.HeaderText = ""
End With
Dim i As Integer
For i = 0 To frmAddCard.CardInStockView.RowCount - 1
Try
If frmAddCard.CardInStockView.Item(3, i).Value = "OFFLINE" Then
frmAddCard.CardInStockView.Columns.Insert(0, _IconColumn1)
Else
frmAddCard.CardInStockView.Columns.Insert(0, _IconColumn)
End If
Catch ex As Exception
End Try
Next
End Sub