Problem with programmatically select next row in the DataGridView control

  • Thread starter £ukasz Margielewski
  • Start date
£

£ukasz Margielewski

I want to program the button, which after clicking on it would have to
utommaticaly select next row in the datagridview control. And I cannot find
how to to this.
This datageidview control datasource is set on the dataview which is connect
to a datatable.
Most important datagridview properties are:
selectionmode = fullrowselect
multiselect = false
Thiese properties allows me to select only one row in the datagridview.

I created also:
DataGridViewRow actuallRecord;

which is set when the datagridview selection is changed by code:



if (dataGridView1.SelectedRows.Count > 0)
{
actuallRecord = dataGridView1.SelectedRows[0];
}

I tried to set actuallRecord on the next row in the datagridview control by
code (located in the button_click funciton):

int indexRekordu = dataGridView1.Rows.IndexOf(aktualnyRekord);
indexRekordu++; // INCREMENTING INDEX
actuallRecord.Selected = false;
actuallRecord = // AND I CANNOT FIND ANY METHOD WHICH WOULD ALLOW ME TO SET
actuallRecord by INDEX
actuallRecord.Selected = true;

Thanks for any help .... maybe I'm blind but I cannot find any solution in
the documentation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top