473,387 Members | 1,295 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Picture and datagridview

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!]
----------------------------------------------------------------
Sep 27 '07 #1
3 8469
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!]
----------------------------------------------------------------

Sep 27 '07 #2
Hi Cor,

tried it but I get a column with the same (red) image on each row :
probably because of this statement :
Dim dc As New TextAndImageColumn
dc.Image = My.Resources.RedImage
dgvPrikbord.Columns.Insert(0, dc)

To change the pic on other rows, this ain't working:
' change the image for the second row
DirectCast(dgvPrikbord.Item(0, 1), TextAndImageCell).Image =
My.Resources.BlueImage
--
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!]
----------------------------------------------------------------
"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!]
----------------------------------------------------------------


Sep 28 '07 #3
"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!]
----------------------------------------------------------------


Sep 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DraguVaso | last post by:
Hi, I'm using the DataGridView in VB.NET 2.0. The DataSource is a Generic List of a custom class0: lstMyPersonnes = New List(Of clsPersonne). When I add a new clsPersonne to lstMyPersonnes,...
10
by: Henok Girma | last post by:
Hello Gurus, I want to save the state of an unbound DataGridView on my Windows Form application to an XML file so i can later load it back.. Basically, on my form I have a DataGridView, it's got...
3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
2
by: bob | last post by:
Can anyone tell me the best way to update a dataset while it is being edited/viewed in the DataGridView control? Is this something that should be inserted into one of the grid's events? or should...
7
by: Mitchell S. Honnert | last post by:
Is there an equivalent of the DataGrid's DataGridTableStyle for the DataGridView? If not, is there an easy way to duplicate the DataGridTableStyle's functionality for the DataGridView? Here's...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
0
by: jeastman - Hotmail | last post by:
Hello world Excuse, not to be written English and it helps me with a translator. I am new programming in C#. I made a control inheriting the DataGridView to be able to add controls done by...
3
by: Andrus | last post by:
I have DataGridView in virtual mode containing 3500 rows. In code below, assigning to RowCount value to 3500 takes 8 seconds. CPU usage goes high at this time. Stepping by F11 into user code shows...
0
by: priyamtheone | last post by:
I'm trying to make a datagridview column to act like a datetimepicker column (C#.Net 2005). These are the behaviours that the dgv should have: 1) Initially all the cells of the dtp column should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.