"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:31**********************************@microsof t.com...
Is this what you are searching for?
http://www.vb-tips.com/TextAndImageColumn.aspx
Cor
" Screaming Eagles 101" <se*********@online.pleaseschreef in bericht
news:46***********************@news.skynet.be...
>Hi,
is there an easy way to add a picture(box) to a column in a datagridview
?
My first column has a code, ex. 1, 2 or 3
According to these codes I'dd like to add a picture(box)
to my second column, just at the time when I show the data in the grid.
I don't save the pictures in the database, I only use them when I show
the data in the grid.
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------
Actualy, after googling the whole afternoon and pulling hair, I managed to
put up something and it looks real simple,
no need to write hundreds of lines of code one doesn't understand if they
are only as smart as I am :-/
What I did can be done in 30 seconds :
1. I added this statement on top, this is to remove the red crosses where
you don't need an image in the imagecolumn
Private myBmp As Bitmap = New Bitmap(16, 16) 'to avoid red crosses
2. Then I added on designtime (can also be done
at runtime I guess...) a column to the grid,
of type DataGridViewImageColumn.
3. And then, to terminate, I add this routine
(I have 3 possible values in column 4 of my grid,
I add an image in column 0 (imagecolumn)
out off my resource file
according to the value in column 4)
that's it, no more, no less :
Private Sub dgvPrikbord_CellFormatting(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellFormattingEve ntArgs) Handles
dgvPrikbord.CellFormatting
If e.ColumnIndex = 0 Then
If dgvPrikbord(4, e.RowIndex).Value = "INFO" Then
e.Value = My.Resources.ResEN.info
ElseIf dgvPrikbord(4, e.RowIndex).Value = "TI" Then
e.Value = My.Resources.ResEN.ti
ElseIf dgvPrikbord(4, e.RowIndex).Value = "IP" Then
e.Value = My.Resources.ResEN.ip
Else
e.Value = myBmp 'avoid red crosses
End If
End If
End Sub
--
Filip
http://www.ww2airborne.net/
Official Site of the 101st Airborne - 463rd PFA
skype: airborne463pfa-fiwi
[It's nice to be important, but it's more important to be nice!]
----------------------------------------------------------------