Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataGridViewButtonColumn
Message
From
14/08/2007 15:51:28
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB 8.0
Miscellaneous
Thread ID:
01247931
Message ID:
01248143
Views:
27
>In my application, I have a DataGridViewbuttonColumn manually added to my DataGridView that I use to zoom in on a record. It works great.
>
>I want to try to pretty up the button a little bit. Instead of just saying "Zoom", I would like a button with a magnifying glass on it, or something like that. Does anybody know how to do this?

>
>Hey Mike,
>
>There are probably dozens of ways to do this. Here's how I do it, by adding an icon column. I create a ButtonField object, set some properties, and add the object to the GridView.
>
>
>
>ButtonField obt = new ButtonField();
>obt.CommandName = "Select";
>obt.ButtonType = ButtonType.Image;
>obt.ImageUrl = "openfolder.ico";   // or whatever icon you want
>
>this.grdResults.Columns.Add(obt);
>
>
>I'm guessing you already know this - clicking the button will fire the gridview's SelectedIndexChanged event, where you can grab the current gridview row.
>
>Let me know if that helps...
>
>P.S. I just realized that my brain is fried tonight - I pasted in some code from a webforms app. good grief! Well, the code may or may not work, sorry.
>
>
>
>Kevin

Here is the code that ended up working. I am not 100% satisfied as it is just an image in the column instead of a button and it might not be evident to the user that they can click it, but I think it will work better than a button with "View" written on it.
        imageColumn = New DataGridViewImageColumn
        imageColumn.Width = 16
        imageColumn.ValuesAreIcons = False
        imageColumn.Image = System.Drawing.Image.FromStream(myStream)
        imageColumn.ReadOnly = True
        grdPreapprovals.Columns.Add(imageColumn)
Very fitting: http://xkcd.com/386/
Previous
Reply
Map
View

Click here to load this message in the networking platform