473,386 Members | 1,621 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,386 software developers and data experts.

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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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 3878
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.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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 "DataBindings" 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.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.comwrote in message
news:11**********************@f16g2000cwb.googleg roups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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.nospamwrote in message
news:%2****************@TK2MSFTNGP02.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 "DataBindings" 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.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.comwrote in message
news:11**********************@f16g2000cwb.google groups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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.nospamwrote in message
news:%2****************@TK2MSFTNGP02.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 "DataBindings" 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.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.comwrote in message
news:11**********************@f16g2000cwb.google groups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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.nospamwrote in message
news:%2****************@TK2MSFTNGP02.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 "DataBindings" 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.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.comwrote in message
news:11**********************@f16g2000cwb.googleg roups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.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.nospamwrote in message
news:%2****************@TK2MSFTNGP02.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 "DataBindings"
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.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.comwrote in message
news:11**********************@f16g2000cwb.google groups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.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.nospamwrote in message
news:%2****************@TK2MSFTNGP02.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 "DataBindings"
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.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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.comwrote in message
news:11**********************@f16g2000cwb.googleg roups.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(Column1, Column2, Column3)

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

So for example...

Me.My_DataGrid.Rows.Add(Column1, 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
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...
0
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
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...
0
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...
1
by: vi2psn | last post by:
How to Add images in datagrid
2
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...
1
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
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();...
1
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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...

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.