Solved

How do I create a button control column in my VS 2005 datagrid?

Posted on 2006-06-24
1
192 Views
Last Modified: 2010-04-23
I am using VS 2005 to develop a Windows application in VB.Net.

How do I add a button control column to a datagrid so that I can handle the button click event when it is selected by a user?

Bob
0
Comment
Question by:bobsegrest
1 Comment
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 16976762
In VB.NET 2005 the DataGridView is the replacement for the DataGrid (although the latter is still available if you prefer it).  So far as providing the button control in the DataGridView is concerned, see this

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewbuttoncolumn.aspx

As to handling the click event, see this

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.cellcontentclick.aspx

Unlike with some other types of columns, a buttoncolumn will react to the click event immediately.  The DataGridViewCellEventArgs expose a .ColumnIndex property (so you can determine if it is a buttoncolumn) and, if it is, also a .RowIndex property (so you can identify the record concerned) and pass that to any sub/function that you want to run on the button_click.

If you really do want to use a DataGrid, rather than a DataGridView, have a look at this

http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q888q

Roger
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question