How can I select a cell in DataGridView ? RRS feed

  • Question

  • Hi,

    I want to select a cell in dataGridView and use this code :

    dataGridView1.Rows[j].CellsIdea.Selected = true;

    that i , j are not out of range but this exception occured:

     Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function.

    after that I derived a class from DataGridView and use

    SetCurrentCellAddressCore(i, j, true, true, false)  to select cell but this exception occured:

    Specified argument was out of the range of valid value.

    Please help me.





    Tuesday, March 14, 2006 8:00 AM

All replies

  • You do it the good way, only your index j is out of range. This means he is lower then 0 or greater then the number of rows that are in the DataGridView.
    Tuesday, March 14, 2006 8:12 AM
  • Dear,

    the j index is not out of range for example I have a grid with 6 row and 7 column and I set j=3 and i=3 .

    but that exception occured .

    Tuesday, March 14, 2006 8:32 AM