?
Solved

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

Posted on 2006-06-24
1
Medium Priority
?
195 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 2000 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

Technology Partners: 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 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