Android Question how to refer cells content on B4XTable ?

omarruben

Active Member
Licensed User
Longtime User
Hello, is it possible to get and set a specific cell values and change the background color or format elements using numbers as indexes:

B4XTablexxxxxx.cell(5,4).value ="10"
or
B4XTablexxxxxx.cell(5,4).backgorundcolor ="red"
 

omarruben

Active Member
Licensed User
Longtime User
I know this is one way to set , how to get value ?????? or how to set styles of one cell????
B4X:
Sub setValue(xtable As B4XTable, xRow As Int, xCol As Int, xValue As String)
    Dim colName As String = nameDays(xCol)                                          
    Dim column As B4XTableColumn = xtable.GetColumn(colName)     '----> also, can this be a number instead a name ID?
    xtable.sql1.ExecNonQuery2($"UPDATE data SET ${column.SQLID}  = ? WHERE rowid = ?"$, Array As String(xValue, xRow))
    xtable.Refresh
End Sub
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Tested in B4J but should be good ...

B4X:
Sub Button1_Click ()
    Dim row As Int = 5   'row 5 ...
    Dim value As String = GetCellValueandSetColor("Name", row, xui.Color_Green)  
    Log(value)
End Sub


Sub GetCellValueandSetColor(columnID As String, rowID As Int, color As Int) As String
 
    Dim column As B4XTableColumn = B4XTable1.GetColumn(columnID)
    'For i = 1 To column.CellsLayouts.Size -1  '  to loop thru all rows in Column ... replace (rowID) in line below.
        Dim pnl As B4XView = column.CellsLayouts.Get(rowID) 
        pnl.GetView(0).TextColor = xui.Color_Green 
        Return pnl.GetView(0).text
        
        'Dim lbl As Label = pnl.GetView(0)  ... non B4X style        
 
End Sub
 
Upvote 0

omarruben

Active Member
Licensed User
Longtime User
thank you so much , I will try today
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…