Hi Jean-Michel,
You are probably setting a certain row as selected, but the black triangle cursor follows the CurrentRow property. The CurrentRow property is a read only property that follows CurrentCell, which you can set.
Try setting the CurrentCell property to a cell in the desired row.
dataGridView1.CurrentCell = dataGridView1.Rows[2].Cells[0];
> During the initialization, I set the current selected row to the first row
> of my DataGridView.
[quoted text clipped - 5 lines]
> Thanks for your help,
> Jean-Michel

Signature
Happy coding!
Morten Wennevik [C# MVP]
david.vincent@ufo.org - 11 Jun 2007 21:21 GMT
Thanks Wenning.
I always get an error "Current cell cannot be set to an invisible cell.",
both with CurrentCell and FirstDisplayedCell, even with grids with no
invisible column.
Is there a test to perform before?
Morten Wennevik [C# MVP] - 12 Jun 2007 15:47 GMT
> Thanks Wenning.
> I always get an error "Current cell cannot be set to an invisible cell.",
> both with CurrentCell and FirstDisplayedCell, even with grids with no
> invisible column.
> Is there a test to perform before?
Well I don't know what your grid looks like, but you can test for visibility before assigning the CurrentCell
DataGridViewCell cell = dataGridView1.Rows[2].Cells[0];
if(cell.Visible)
dataGridView1.CurrentCell = dataGridView1.Rows[2].Cells[0];
You may also need to ensure the data is fed to the grid before trying to assign the CurrentCell. In my sample I filled the DataGridView in the form constructor and set the CurrentCell property in the Form.Load event, however my code worked fine if I set the CurrentCell in the constructor as well.

Signature
Happy coding!
Morten Wennevik [C# MVP]