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.
>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.