Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / July 2008

Tip: Looking for answers? Try searching our database.

PushButtons in Datagrid

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fripper - 20 Jul 2008 01:14 GMT
I posted this question about a week ago and did not get any responses ... I
am thinking that maybe I wasn't clear and would like to try again.

I have a datagrid that has two Button columns ... both of them of type
PushButton.  I cannot figure out how, when one of these buttons is clicked
in a row and the SelectedIndexChanged event fires, to identify which of the
two buttons was clicked ... the one in, say, column 3 or the one in column
7?

Thanks for any help.
Jack Jackson - 20 Jul 2008 08:25 GMT
>I posted this question about a week ago and did not get any responses ... I
>am thinking that maybe I wasn't clear and would like to try again.
[quoted text clipped - 6 lines]
>
>Thanks for any help.

SelectedIndexChanged fires when the selected row in the DataGridView
changes.  It may fire for reasons other than a button push, and a
button push may not cause the selected row to change.

You want to detect clicks on the buttons, not row changes.  From the
MSDN documentation for DataGridViewColumnButton:

To respond to user button clicks, handle the
DataGridView..::.CellClick or DataGridView..::.CellContentClick event.
In the event handler, you can use the
DataGridViewCellEventArgs..::.ColumnIndex property to determine
whether the click occurred in the button column. You can use the
DataGridViewCellEventArgs..::.RowIndex property to determine whether
the click occurred in a button cell and not on the column header.
fripper - 20 Jul 2008 20:34 GMT
Thanks very much ... now I have a better understanding of how clicks in
datagrids work ...

>>I posted this question about a week ago and did not get any responses ...
>>I
[quoted text clipped - 23 lines]
> DataGridViewCellEventArgs..::.RowIndex property to determine whether
> the click occurred in a button cell and not on the column header.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.