Saturday, July 08, 2006

DataGridViewButtonColumn

I've just started experimenting with the new DataGridView control in 2.0. I've learned a couple interesting things so far while trying to create some button columns.

First, in order to display text on the DataGridViewButtonColumn you must not only set the Text property, but must also set the UseColumnTextForButtonValue to true.

You cannot load an image on to a DataGridViewButtonColumn. Instead you must use a DataGridViewImageControl and capture the cellclick event to treat it like a button.

3 comments:

Edelman said...

I'm having this problem right now...I started a blog recently kind of like yours, but I guess with my own problems.

dotnetdiscussion.wordpress.com

Maybe you can help me out with what's going on? Maybe I can help you out w/something?

Thanks for any help in advance.

-Jason

CreaTek Solutions said...

Hmm. I haven't used this in a long time. The difference may be something specific to VB.NET - I was using C#.

To get around it for now, you may try using any column type that you can get text to display on, and then capturing the cellclick event to treat it like a button.

Edelman said...

yeah i've heard that the only thing that makes a button column a button column is that it looks like a button graphically. ha. oh well. i hate workarounds, but in programming, such is life.