How to Select(highlight) the last row of the datagrid

Jan 22, 2009 at 5:06 AM
Hi,

I am binding different DataTables dynamically for the DataGrid as the ItemSource. After assigning the ItemSource I want to select(highlight) the last row of the datagrid. Is there any easy way to select the last row of the DataGrid?

Thanks!
Jan 22, 2009 at 9:01 AM
Hi,

If you are binding a DataTable you can find its row count from DataTable.Rows.Count, you can then use this to select the last row by setting the DataGrid.SelectedIndex property.

Regards,
Colin E.
--
http://www.scottlogic.co.uk/blog/wpf/ - my WPF blog
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx - WPF DataGrid Practical Examples