| Subject: PushButtons in Datagrid |
| Group: microsoft.public.vstudio.general |
| Date: 7/19/2008 5:14:14 PM |
| From: "fripper" [Email Address Protection] |
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. |
| Back |
| Subject: Re: PushButtons in Datagrid |
| Group: microsoft.public.vstudio.general |
| Date: 7/20/2008 12:25:42 AM |
| From: Jack Jackson [Email Address Protection] |
On Sat, 19 Jul 2008 20:14:14 -0400, "fripper" <young@indiana.edu> wrote: >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. > 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. |
| Back |
| Subject: Re: PushButtons in Datagrid |
| Group: microsoft.public.vstudio.general |
| Date: 7/20/2008 12:34:18 PM |
| From: "fripper" [Email Address Protection] |
Thanks very much ... now I have a better understanding of how clicks in datagrids work ... "Jack Jackson" <jjackson@cinnovations.net> wrote in message news:nup5845nuk1g21i9se69ikpt7edchobp59@4ax.com... > On Sat, 19 Jul 2008 20:14:14 -0400, "fripper" <young@indiana.edu> > wrote: > >>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. >> > > 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. |
| Back |