1
Reply

How to NOT select a cell?

Sach

Sach

Oct 28 2008 1:03 AM
2.5k
In my C# Application program, I have two DataGridViews which are not bound to any data source. I have coded them so that the user is allowed to drag and drop data between the two DGVs as well as within them.
So, when a data item in a cell is dragged and dropped on another cell, the data on the original is deleted - that is set to null.
The problem is, when I do that, after dropping, it automatically select the last cell (the one in which I just set the value to null).
How do I get that cell to be NOT selected?

Here is my code:


dgvSchedule.DoDragDrop(text, DragDropEffects.Copy);
if (bDataDrop == true)
{
           dgvSchedule.Rows[info.RowIndex].Cells[info.ColumnIndex].Value = null;         //setting the value to null
           dgvSchedule.Rows[info.RowIndex].Cells[info.ColumnIndex].Selected = false;   //setting that cell to not selected
           bDataDrop = false;               
}



There, right after I set the value to null, I set the 'selected' property to false, but despite that it still selects that.

Please HELP!

Answers (1)