dataGridView setting a row

S

Soulless

I have a scenario where I am coding in the cellvaluechanged in case
the user enters some bad data into a cell in a datagridview. The
problem is it crashed during run because I think that there is no
current row selected.

How do i force the system to have the currentrow = 1 for the
datagrid? There will always be one row at least. I am trying various
ways to assign the currentrow, but it does not work.

help please.
 
J

JT

I have a scenario where I am coding in the cellvaluechanged in case
the user enters some bad data into a cell in a datagridview. The
problem is it crashed during run because I think that there is no
current row selected.

How do i force the system to have the currentrow = 1 for the
datagrid? There will always be one row at least. I am trying various
ways to assign the currentrow, but it does not work.

help please.

Hey,

You need to select a cell, not a row. It doesn't seem right, but
that's how it works. Try

YourDataGridView.CurrentCell = YourDataGridView[0, TheRowYouWant];

The first parameter is the column, the second is the row, zero-based,
so adjust depending on whether you mean row 1 (1) or the first row
(0).

JT
 

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