Buttons inside the datagrid

Poochi

Member
Joined
Sep 19, 2006
Messages
6
Programming Experience
Beginner
Hello,

Currently I have a form that displays data from a database in a datagrid. I've also managed to add a column of buttons to the datagrid.

What I want to do is: When the user clicks the button, the data from the corresponding row will be displayed in a textbox.

This seems simple enough, but I can't seem to double-click on the datagrid button and then code the click event like I can with normal buttons. Instead, it just selects the entire datagrid.

Can anyone show me how to implement this?
Thanks.

P.S. I'm using the Express version of VB.NET
 
No, what I mean is, normally when I want to code the click_event for a button, then I just double-click the button in the design view. However, I can't do this because all that happens is that I select the datagrid the button is inside. This creates the click_event stub for the datagrid rather than the button itself.

I want to find a way to code the click_event for the button inside the datagrid. Eg, display that rows data in a text box.
 
I get the feeling that you will have to do this in code because the buttons you see in the designer are just a rendering of the type of the column, they arent actually individual buttons.

I would encourage you to seek an option to fake this instead.. Why not put a click handler on the datagridview itself, and then in the handler, say:

If (datagridviewClickEventObject).Column = (Whichever_Column_number_holds_the_buttons) Then
'show the details of row (datagridviewClickEventObject).Row


I.e. put a click handler on the grid and do some action if a click lands within the column, rather than try to add an eventhandler to one of potentially thousands of buttons

Personally, i wouldnt even have the column of buttons..total waste of screen space! Just attach an event handler to a grid doubleclick and show the contents of whatever row is current (the first click makes some row current)
 
Back
Top