Solved

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

Posted on 2006-06-24
1
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 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