Android Question help..help needed about set color to a row in b4xtable

spiroskaras

Member
Licensed User
Longtime User
When i set a color in a row of a multiple pages b4xtable is coloring the same in order row to the next page.
i am using the ready made code from forum

Sub setrowcolor(in As Int)
Dim RowIndex As Int = in 'the 5th Table Row
Dim SelectionColor As Int = 0xFFFFD700
For Each c As B4XTableColumn In B4XTable1.VisibleColumns
Dim pnl As B4XView = c.CellsLayouts.Get(RowIndex + 1) '+1 because of the header
pnl.Color = SelectionColor
Next
End Sub
 

Mahares

Expert
Licensed User
Longtime User
When i set a color in a row of a multiple pages b4xtable is coloring the same in order row to the next page.
Here is a solution that will color the 5th row with the color of your choice and leave the rest the same color. I hope I understood your question:
B4X:
Sub B4XTable1_DataUpdated    
    SetRowColor(4)    '5th row
End Sub

Sub SetRowColor(in As Int)    'rowid-1
    Dim SelectionColor As Int = 0xFFFFD700
    For i = 0 To B4XTable1.VisibleRowIds.Size - 1
        Dim RowId As Long = B4XTable1.VisibleRowIds.Get(i)
        For Each c As B4XTableColumn In B4XTable1.Columns
            Dim pnl As B4XView = c.CellsLayouts.Get(i+1)            
            If RowId = in+1 Then
                pnl.Color=SelectionColor
            Else
                If i Mod 2 = 0 Then
                    pnl.Color = B4XTable1.EvenRowColor
                Else
                    pnl.Color = B4XTable1.OddRowColor
                End If
            End If
        Next
    Next
End Sub
Please use code tags
 
Upvote 1
Top