Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically select a row in UITableView in MonoTouch?

I know you can select a row in a UITableView by calling UITableView.SelectRow function, but I'm having trouble to construct the first parameter NSIndexPath for the given row number. This is the code I tried:

NSIndexPath path = new NSIndexPath() { Row = 3 };
tableView.SelectRow(path, false, UITableViewScrollPosition.None);

But it doesn't compile because Row is read-only.

Or maybe there is a different way to do it?

like image 811
newman Avatar asked Nov 21 '11 02:11

newman


Video Answer


1 Answers

Use the NSIndexPath.FromRowSection static method instead:

NSIndexPath path = NSIndexPath.FromRowSection(3, 0);
like image 50
Dimitris Tavlikos Avatar answered Sep 24 '22 18:09

Dimitris Tavlikos