Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How NOT to select a cell in DGV

SachinthaSachintha Member Posts: 6
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!
Sign In or Register to comment.