Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now