Hello IceTeaGroup
I’m working with a DataGridView with different CellTypes. I added the CellClickEvent to handle wich Cell was clicked.
I placed a DataGridView to a Panel, set up the columns in the property window / columneditor to use every type of possible ColumnType (DataGridViewButtonColumn, DataGridViewCheckBoxColumn and so on).
In codebehind I just used
DataGridViewRow row = new DataGridViewRow();
dataGridView.Rows.Add(row);
to add a DataGridViewRow to the DataGridView.
My ClickEvent looks like this:
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
DataGridView mainSender = (DataGridView)sender;
MessageBox.Show(mainSender.CurrentCell.GetType().FullName);}
The issue what I got is, the CurrentCell property isn’t updated propabbly. So I click on an ImageCell and get the message output: “Wisej.Web.DataGridViewCell”, next I click on a ButtonCell and get the previous clicked: “Wisej.Web.DataGridViewImageCell”
Am I doing something wrong or is it a real issue?
Best regards
Marcel
Use the e.ColumnIndex, e.RowIndex passed in the event. The CurrentCell is the cell with the focus frame which may not be the one clicked. datagridview[e.ColumnIndex, e.RowIndex].
Please login first to submit.