Starting on Blank Row in DataGrid

  • Thread starter Thread starter Junkguy
  • Start date Start date
J

Junkguy

Does anyone know the best way to put the cursor in the "blank" row of an
editable datagrid when it is initially displalyed?

I need to present the user with a list of rows from a dataset, but I want to
put the cursor in the first cell of the blank row so they can begin adding
data immediately instead of scrolling to the bottom.

Thanks in advance.
 
Hi,
Just create a DataSet with one empty DataRow and bind to
the datagrid.

Regards,
Amal
 
Amalorpavanathan Y \(Amal\) said:
Hi,
Just create a DataSet with one empty DataRow and bind to
the datagrid.

Regards,
Amal

Thanks,

My issue is that I have a DataSet with existing rows in it already. The
DataSet is bound to the DataGrid and I call someDataAdapter.Fill(theDataSet)
which fills the DataSet and presents it in the DataGrid. I want to place the
cursor for the user at the very bottom of this list in the "blank" row so the
user can start typing in new data without scrolling to the bottom. I need to
know the correct (read non-hack) way to do this.
 
I think that;

datagrid.currentRowindex = dataset.tables[strTableName].Rows.count;

should work. If you're using a dataview, access the dataviews' rows.count
property

HTH,

Marco
 
Back
Top