Posted 7 December 2018, 3:28 am EST
Hi,
As I said earlier, C1TrueDBGrid uses two styles: one for ActiveCell and one for SelectedCell; SelectedRows.Clear() clears the selected rows. In your case, you want to clear the active cell.
Please also note that DataGridView also always has an active cell, just like TrueDBGrid.
You can observe this if you use this code with DataGridView:
dataGridView1.ClearSelection();
int row = dataGridView1.CurrentCell.RowIndex;
int col = dataGridView1.CurrentCell.ColumnIndex;
You’ll see that row and col would be assigned valid indexes (since a cell is still active).
DataGridView’s ClearSelection() method only removes the styling from the grid, until a cell is again clicked.
You can get the same behaviour in C1TrueDBGrid if you set MarqueeStyle to NoMarquee in the beginning, and once the grid is clicked, restore the original MarqueeStyle.
I’ve also modified the earlier sample so that it works exactly like DataGridView. There is no highlighted cell at the beginning, a cell is only highlighted once a click is performed on any cell.
I hope it clears the confusion.
Regards,
Jitender
ClearSelection_Modified.zip