Solved

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

Posted on 2006-06-24
1
191 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

776 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