Get the row CellType of CustomCell iOSTable

Hi there,
I have a iOSTable with different CustomCells for each Row, and at LoadTable() I access different controls on each type and set some Textfields.

Then, by pressing Toolbar (Save) I would like to Loop Through all Rows in the iOSTable and fetch the data that is typed in each row and save the Answers to SQLite. But as each Row contains different CustomCellType, how can I get the Type of each row? so I can make a Select Case and fetch the data from the correct field? Here’s how I create the table:

While Not rs.EOF
Var QuestType As QuestionTypes = CType(rs.Field(“Type”).IntegerValue, QuestionTypes)
Var cell As iOSTableCellData

Select Case QuestType

Case QuestionTypes.Text
cell = tbl_ReportQuestions.CreateCustomCell(GetTypeInfo(Question_Textbox))
Dim container As Question_Textbox = Question_Textbox(cell.Control)

container.SetValues( _
rs.Field("ID").IntegerValue, _
rs.Field("Question").TextValue, _
rs.Field("Answer").TextValue _
)

Case QuestionTypes.Boolean
cell = tbl_ReportQuestions.CreateCustomCell(GetTypeInfo(Question_Boolean))
Dim container As Question_Boolean = Question_Boolean(cell.Control)

Case QuestionTypes.Number
cell = tbl_ReportQuestions.CreateCustomCell(GetTypeInfo(Question_Number))
Dim container As Question_Number = Question_Number(cell.Control)

Case QuestionTypes.Rating
cell = tbl_ReportQuestions.CreateCustomCell(GetTypeInfo(Question_Rating))
Dim container As Question_Rating = Question_Rating(cell.Control)

Case QuestionTypes.Selector

Case QuestionTypes.Signature

End Select
cell.Tag = rs.Field(“ID”).IntegerValue
Me.tbl_ReportQuestions.AddRow(0, cell)

rs.MoveNext
Wend

If you are displaying more than 20 rows I would recommend going with a datasource.
But that would also mean internally saving each edit to a cell as soon as it is edited, because when a user scrolls, the edit would be lost.

With your current implementation this should help, note my code is untested:

For section as Integer = 0 to tbl_Report.SectionCount-1
For row as integer = 0 to tbl_Report.Rowcount(section)-1

Var cell As iOSTableCellData = me.RowData(section, row)
Var info As Xojo.Introspection.TypeInfo = Xojo.Introspection.GetType(cell)
Select case info.name
Case "Question_Textbox"
Dim container As Question_Textbox = Question_Textbox(cell.Control)
//Get the Container values

Case "Question_Boolean"
Dim container As Question_Boolean = Question_Boolean(cell.Control)
//Get the Container values
End Select

Next
Next

It was the Array I’ve got wrong. For some reason I could not access the Textfield Controls, so I had to create a Property and access that instead…