Short solution for short problems

iOS: Programatically select a row in a tableview

Very simple thing, very simple code. Just putting it here for future use. Mind you that when you preform the selectRowAtIndexPath method, the didSelectRowAtIndexPath is not called. So you will need to trigger this manually.

Here's the code for how to select a row in your UITableView from code:

NSIndexPath * indexPath = [NSIndexPathindexPathForRow:0inSection:0];

[self.tableViewselectRowAtIndexPath:indexPath animated:YESscrollPosition:UITableViewScrollPositionNone];

How to rebind a Select on a datatable?

If you have for example a data grid that binds to a dataset or data table and you perform a Select(“”) on the table, it can happen that you lose your bindings and the row is shown but the values not:
The code I used was like this:

grdProjectOverview.DataSource = dt.Select("ProjectEndDate > '" + DateTime.Now.ToShortDateString() + "'");

The system finds the correct number of rows and displays them, but the values are not in there. I solved it by using a dataview like this:

grdProjectOverview.DataSource = new DataView(dt, "ProjectEndDate > '" + DateTime.Now.ToShortDateString() + "'", String.Empty, DataViewRowState.CurrentRows);

Now the binding works and the values are shown. It  can really be a pain to get this one solved. Unfortunately as always I do not have time to dig into this deeper. So just the quick solution:

Binding doesn't track (pick up) the change if you programatically edit a control.

I'm working on a windows forms application that uses binding to update the contents of the controls. Works like a charm.
When the form got a little more complicated and controls where addedd dynamically, it got a little tricky.
When I changed the value of the controls programatically, the change was not picked up by the bindings. I didn't had to look very long for a solution.
I just added a .Focus or a .Select and then the binding picks up the change.
By example:
txtVersion.Text = versionNum.ToString
txtVersion.Text = versionNum.ToString