How do you select/highlight the first row of a table that uses custom cells?

I try me.selectrow(0,0) in the table open event but it gives an outofbounds error, so I tried using a timer thinking it hadn’t created the custom cells on opening in time but get the same error. If I use a timer on a normal table without custom cells it highlights the first row??

DataTable.AddSection("My Styles")
  db.DatabaseFile = dbfile
  if db.connect then
    IsConnected = True
    var rs as rowset = db.SelectSQL("select * from Team")
    myrowcount = rs.RowCount
    for each r as DatabaseRow in rs
      Var cell As MobileTableCellData = DataTable.CreateCustomCell(GetTypeInfo(TeamCustomCell))
      Var container As TeamCustomCell = TeamCustomCell(cell.Control)
      container.TeamLogo.Image = RushDataTable
      container.DBidLabel.Text = rs.Column("ID").StringValue.ToText
      container.TeamNameLabel.Text = rs.Column("Name").StringValue.ToText
      container.AddressLabel.Text = rs.Column("Address").StringValue.ToText
      container.PhoneLabel.Text = rs.Column("Mobile").StringValue.ToText
  end if
catch e as DatabaseException
  system.DebugLog e.Message
end try

No Advice suggests I am missing something or suppose to know something or I have asked an obvious question :slight_smile:

When you say “custom cells” I suppose you mean you’re using a data source?

Edit: rereading, I see that you are not.

As you’re pulling data from a database, you might want to consider it.

You’re sure that you’re not getting dumped into that exception block, right?

Hi Greg
Confirmed it is not exception block.
it has two sql lite databases that I create on launch of various screens with custom cells for the columns which all works fine except I can’t highlight the first row

This might make it easier to help.
There is an IOS example called ‘Custom Cells and Scrolling’
What code would you add to highlight the first entry?

me.selectrow(0,0) doesn’t work in the open event

If that’s not working, I’d probably use a declare.

That said though… iOS tables typically don’t have a persistent selection. It might be worth taking a second look at your UI to make sure you’re following the iOS user interface guidelines.

I eventually got it working with a timer :+1: just needed a longer delay