473,651 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET Datagrid with pictures

Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.

Oct 16 '06 #1
8 3889
I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the path of
the image (which is stored in my database along with the other data for that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ f16g2000cwb.goo glegroups.com.. .
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.

Oct 17 '06 #2
I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the path of
the image (which is stored in my database along with the other data for that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ f16g2000cwb.goo glegroups.com.. .
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.
Oct 17 '06 #3
You need to add "Template" columns to your DataGrid first....

1. Right click on your grid and choose "Property Builder"
2. Select the "Columns" category on the left side
3. Select a "Bound Column" from the "Available Columns" section
4. Click the ">" button to add a bound column to the "Selected Columns"
section
5. Enter the field name from your data source you want to bind to in the
"DataField" textbox.
(this should be the name of the field in your database that contains
the image path)
6. Now, click the hyperlink at the bottom of the window that says "Convert
this column into a Template column"
7. Type what you want this column to have as header text in the "Header
Text" textbox
8. Click OK
9. Right click on your grid and choose "Edit Template" and when the sub
menu appears choose the new column you just added.
10. There will already be a label control in the "Item Template" section of
the screen you see. Select it and look at its "DataBindin gs" property
(you'll need to click the "..." button to get there.
11. Select the whole "Custom Binding Exression" text & click "Cancel"
12. Now, delete the label control and replace it with an Image control.
13. Go into the DataBindings property and paste in the same text you just
copied out of the label.

Assuming the rest of your DataGrid's code is set up to bind to its data
source, you should now have an image in your grid.
"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
>I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the path of
the image (which is stored in my database along with the other data for
that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11******* *************** @f16g2000cwb.go oglegroups.com. ..
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.

Oct 17 '06 #4
Thank you scott,

I was reading the posts and I seen this one and wondered how to do this.

I would have also had to ask this about a month later.
Thank you for the step by step example.

Miro

"Scott M." <s-***@nospam.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
You need to add "Template" columns to your DataGrid first....

1. Right click on your grid and choose "Property Builder"
2. Select the "Columns" category on the left side
3. Select a "Bound Column" from the "Available Columns" section
4. Click the ">" button to add a bound column to the "Selected Columns"
section
5. Enter the field name from your data source you want to bind to in the
"DataField" textbox.
(this should be the name of the field in your database that contains
the image path)
6. Now, click the hyperlink at the bottom of the window that says
"Convert this column into a Template column"
7. Type what you want this column to have as header text in the "Header
Text" textbox
8. Click OK
9. Right click on your grid and choose "Edit Template" and when the sub
menu appears choose the new column you just added.
10. There will already be a label control in the "Item Template" section
of the screen you see. Select it and look at its "DataBindin gs" property
(you'll need to click the "..." button to get there.
11. Select the whole "Custom Binding Exression" text & click "Cancel"
12. Now, delete the label control and replace it with an Image control.
13. Go into the DataBindings property and paste in the same text you just
copied out of the label.

Assuming the rest of your DataGrid's code is set up to bind to its data
source, you should now have an image in your grid.
"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
>I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
>>I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the path
of
the image (which is stored in my database along with the other data for
that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11****** *************** *@f16g2000cwb.g ooglegroups.com ...
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid .Rows.Add(Colum n1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid .Rows.Add(Colum n1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do
I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.


Oct 17 '06 #5
Oops! Add this:

11a: Copy the selected text to the clipboard

"Scott M." <s-***@nospam.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
You need to add "Template" columns to your DataGrid first....

1. Right click on your grid and choose "Property Builder"
2. Select the "Columns" category on the left side
3. Select a "Bound Column" from the "Available Columns" section
4. Click the ">" button to add a bound column to the "Selected Columns"
section
5. Enter the field name from your data source you want to bind to in the
"DataField" textbox.
(this should be the name of the field in your database that contains
the image path)
6. Now, click the hyperlink at the bottom of the window that says
"Convert this column into a Template column"
7. Type what you want this column to have as header text in the "Header
Text" textbox
8. Click OK
9. Right click on your grid and choose "Edit Template" and when the sub
menu appears choose the new column you just added.
10. There will already be a label control in the "Item Template" section
of the screen you see. Select it and look at its "DataBindin gs" property
(you'll need to click the "..." button to get there.
11. Select the whole "Custom Binding Exression" text & click "Cancel"
12. Now, delete the label control and replace it with an Image control.
13. Go into the DataBindings property and paste in the same text you just
copied out of the label.

Assuming the rest of your DataGrid's code is set up to bind to its data
source, you should now have an image in your grid.
"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
>I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
>>I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the path
of
the image (which is stored in my database along with the other data for
that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11****** *************** *@f16g2000cwb.g ooglegroups.com ...
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid .Rows.Add(Colum n1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid .Rows.Add(Colum n1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do
I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.


Oct 17 '06 #6
Scott,

Although I truly appreciate the effort I believe that your instructions
are refering to a datagrid in ASP.NET, the type that I'm refering to is
for VB.NET on a form.
Scott M. wrote:
Oops! Add this:

11a: Copy the selected text to the clipboard

"Scott M." <s-***@nospam.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
You need to add "Template" columns to your DataGrid first....

1. Right click on your grid and choose "Property Builder"
2. Select the "Columns" category on the left side
3. Select a "Bound Column" from the "Available Columns" section
4. Click the ">" button to add a bound column to the "Selected Columns"
section
5. Enter the field name from your data source you want to bind to in the
"DataField" textbox.
(this should be the name of the field in your database that contains
the image path)
6. Now, click the hyperlink at the bottom of the window that says
"Convert this column into a Template column"
7. Type what you want this column to have as header text in the "Header
Text" textbox
8. Click OK
9. Right click on your grid and choose "Edit Template" and when the sub
menu appears choose the new column you just added.
10. There will already be a label control in the "Item Template" section
of the screen you see. Select it and look at its "DataBindin gs" property
(you'll need to click the "..." button to get there.
11. Select the whole "Custom Binding Exression" text & click "Cancel"
12. Now, delete the label control and replace it with an Image control.
13. Go into the DataBindings property and paste in the same text you just
copied out of the label.

Assuming the rest of your DataGrid's code is set up to bind to its data
source, you should now have an image in your grid.
"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the path
of
the image (which is stored in my database along with the other data for
that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11******* *************** @f16g2000cwb.go oglegroups.com. ..
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how do
I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.

Oct 17 '06 #7
Yes, you are right Matt. Sorry, I didn't realize you wanted a Windows Forms
answer. Honestly, I don't do much work in WinForms, so I really can't offer
a suggestion on this.

Sorry!

Good luck.

"Matt" <Kr****@gmail.c omwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Scott,

Although I truly appreciate the effort I believe that your instructions
are refering to a datagrid in ASP.NET, the type that I'm refering to is
for VB.NET on a form.
Scott M. wrote:
>Oops! Add this:

11a: Copy the selected text to the clipboard

"Scott M." <s-***@nospam.nosp amwrote in message
news:%2******* *********@TK2MS FTNGP02.phx.gbl ...
You need to add "Template" columns to your DataGrid first....

1. Right click on your grid and choose "Property Builder"
2. Select the "Columns" category on the left side
3. Select a "Bound Column" from the "Available Columns" section
4. Click the ">" button to add a bound column to the "Selected
Columns"
section
5. Enter the field name from your data source you want to bind to in
the
"DataField" textbox.
(this should be the name of the field in your database that
contains
the image path)
6. Now, click the hyperlink at the bottom of the window that says
"Convert this column into a Template column"
7. Type what you want this column to have as header text in the
"Header
Text" textbox
8. Click OK
9. Right click on your grid and choose "Edit Template" and when the
sub
menu appears choose the new column you just added.
10. There will already be a label control in the "Item Template"
section
of the screen you see. Select it and look at its "DataBindin gs"
property
(you'll need to click the "..." button to get there.
11. Select the whole "Custom Binding Exression" text & click "Cancel"
12. Now, delete the label control and replace it with an Image
control.
13. Go into the DataBindings property and paste in the same text you
just
copied out of the label.

Assuming the rest of your DataGrid's code is set up to bind to its data
source, you should now have an image in your grid.
"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the
path
of
the image (which is stored in my database along with the other data
for
that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11****** *************** *@f16g2000cwb.g ooglegroups.com ...
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find
anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid .Rows.Add(Colum n1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid .Rows.Add(Colum n1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how
do
I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.


Oct 17 '06 #8
I actually figured it out last night. You have to create an Image
object and pass it in like you would a string.

But thanks to everyone for your efforts!

Cheers
Scott M. wrote:
Yes, you are right Matt. Sorry, I didn't realize you wanted a Windows Forms
answer. Honestly, I don't do much work in WinForms, so I really can't offer
a suggestion on this.

Sorry!

Good luck.

"Matt" <Kr****@gmail.c omwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Scott,

Although I truly appreciate the effort I believe that your instructions
are refering to a datagrid in ASP.NET, the type that I'm refering to is
for VB.NET on a form.
Scott M. wrote:
Oops! Add this:

11a: Copy the selected text to the clipboard

"Scott M." <s-***@nospam.nosp amwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
You need to add "Template" columns to your DataGrid first....

1. Right click on your grid and choose "Property Builder"
2. Select the "Columns" category on the left side
3. Select a "Bound Column" from the "Available Columns" section
4. Click the ">" button to add a bound column to the "Selected
Columns"
section
5. Enter the field name from your data source you want to bind to in
the
"DataField" textbox.
(this should be the name of the field in your database that
contains
the image path)
6. Now, click the hyperlink at the bottom of the window that says
"Convert this column into a Template column"
7. Type what you want this column to have as header text in the
"Header
Text" textbox
8. Click OK
9. Right click on your grid and choose "Edit Template" and when the
sub
menu appears choose the new column you just added.
10. There will already be a label control in the "Item Template"
section
of the screen you see. Select it and look at its "DataBindin gs"
property
(you'll need to click the "..." button to get there.
11. Select the whole "Custom Binding Exression" text & click "Cancel"
12. Now, delete the label control and replace it with an Image
control.
13. Go into the DataBindings property and paste in the same text you
just
copied out of the label.

Assuming the rest of your DataGrid's code is set up to bind to its data
source, you should now have an image in your grid.
"Matt" <Kr****@gmail.c omwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
I'm not sure I understand how to do this scott, could you elaborate a
little bit please?

Thank you :-)
Scott M. wrote:
I've done this by placing an image control in a template column of a
DataGrid and then binding the image control's url property to the
path
of
the image (which is stored in my database along with the other data
for
that
given record).

Works like a charm.

"Matt" <Kr****@gmail.c omwrote in message
news:11******* *************** @f16g2000cwb.go oglegroups.com. ..
Guys I could really use some help with this. I think that it's
probably a simple solution but I haven't been able to find
anything.

I have a datagrid on my form that I populate via code like this...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Column3)

Well now I have a datagrid that I want to populate with an image.

So for example...

Me.My_DataGrid. Rows.Add(Column 1, Column2, Picture)

How do I do this?

I know I can change the "column type" to an "image" column but how
do
I
add one with code?

The next best thing would to be able to statically add an image and
make it visible or invisible by row.

Any advice would be appreciated.
Oct 18 '06 #9

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

Similar topics

3
2220
by: Chumley the Walrus | last post by:
IN my code behind .vb page for a delete records script (this also does a deletion confirmation with a javascript popup, this gets called on my front .aspx page with the datagrid), I'm not sure if he row.delete() in my Delete_Row sub is correct because when deleting a record from the dbase, it doesnot get deleted from the actual database, even tho on the datagrid it does show that the record is deleted: '''''''''''''
0
1055
by: serge calderara | last post by:
Dear all, Is it possible to display a samll picture or icon within a datagrid control in a similar way as a ListView control ? if yes how thnaks for your reply regards
2
1947
by: Celine | last post by:
I am building a website using C#, asp.net and SqlServer. I need to store a lot of images in my database. I need to store thumbnails but also larger pictures(when user clicks thumbnails a larger picture is displayed). For doing that I was told to store only the URL's. My problem now is how to display these images. I know that the tag <img> is recognised by the datagrid and allow an easy display of a picture. But I don't think storing the...
0
885
by: EMW | last post by:
Hi, I have a datagrid with four template columns. After the user selects something in a listbox, the datagrid is filled with pictures by using an imagebutton. I gave the image argument part the string containing the url of the picture. What I now want is when the user clicks on the picture, a new browser window opens showing that picture in its real size.
1
989
by: vi2psn | last post by:
How to Add images in datagrid
2
2846
by: Tim::.. | last post by:
Hi I'm trying to create a little application that shows an image of a user when you mouseover there details in a datagrid. The datagrid is populated from an Active Directory Database and I presume the best way to create the popup is by using a layer with javascript hide and show... I intend to use a database to store the pictures in and the use the users full name to build a relationship between the database with the images and the...
1
2267
by: Michael Turner | last post by:
Anyone know if you can add a background image to a datagrid, there is a property for colour but not for an image.
2
6750
by: DC | last post by:
Hi, I am doing something like this in the ItemCreated event (ASP.Net 1.1): DataGridItem pagerRow = e.Item; TableCell pagerCell = pagerRow.Cells; Control addedControl = new Control(); addedControl.ID = "addedControl"; pagerCell.Controls.Add(addedControl);
1
2689
by: rascalking | last post by:
Hello, So I've read many forums that explained how to get an image out of SQL Server database and display it. I used an alternate .aspx page to retrieve the image and write it back as binary which everyone on many sites said to do. The problem is its not working. My exact situation is that I am creating News Articles based on news entries which are either text or pictures. I want to display a picture in the datagrid if there is one....
0
8352
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8697
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.