-
July 20th, 2009, 03:23 AM
#1
DataGridView and custom columns
Hey,
Im currently writing a simple app to display some data from a list of objects. Each object has the following members:
- ID
- Name
- Description
- Image
- Value
Now i want to display Name, Description as normal columns, but i want the Image to display an Image, so ive made an DataGridViewImageColumn, but the problem is that the image member is not enough to load the image. There is a repository which is set within the appconfig that specifies where images should be loaded from, so it would need to load an image from:
Code:
string ImageUrl = string.format("{0}/{1}", ConfigurationManager.AppSettings["ImageRepo"], TheCurrentElementsImageMember);
Hope that makes sense, then the value i would ideally like to display in more custom way adding some styling to the cell and adding some other text in there, alot like the ItemTemplate in ASP...
Any advice on these topics would be great!
-
July 21st, 2009, 02:03 AM
#2
Re: DataGridView and custom columns
Quick bump... incase anyone can one line answer my question
-
July 21st, 2009, 02:19 AM
#3
Re: DataGridView and custom columns
I did a DataGridView with a Picture column a while back. All I did was select an 'image' type column from an SQL database as part of my Data Set and attached the Data Set to my DataGridView. It worked fine in that scenario.
How are you adding the rows to your DataGridView. Are you mapping it to a DataSet?
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
July 21st, 2009, 02:27 AM
#4
Re: DataGridView and custom columns
Hey,
Adding an DataGridViewImageColumn in is no worries, thats the easy part. The problem i have is that for each row in the table the image needs to take into account the image repository path, so as mentioned before i cant just tell it that the data member is the Image member of the object, as it needs to be prefixed with the AppConfig settings.
If that makes sense...
Last edited by Grofit; July 21st, 2009 at 03:25 AM.
-
July 21st, 2009, 05:25 AM
#5
Re: DataGridView and custom columns
First try to load the image from the URL you have specified on to a temporary IMAGE type and than add this image to the DatagridviewImage column in the datagrid view.. hope it makes some sense..
-
July 21st, 2009, 05:51 AM
#6
Re: DataGridView and custom columns
Each row has a different image though, i read that i should latch onto the CellFormatting event and in there check its the right column and then if its not loaded, load it in there. Still not sure if this will work yet though
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|