B4J Question [SOLVED] B4XTableSelections refresh is changing column custom format

jroriz

Active Member
Licensed User
Longtime User
I have a B4XTable extended with B4XTableSelections.
This B4XTable has a column with a custom format.
It happens that the B4XTableSelections refresh is changing the colors of the column that was customized.
Is there an easy way to fix this?
Thank you all.

Before refresh:
1614874657329.png

After refresh:
1614874685093.png


Column custom format:
Private Sub FormatarColValor (c As B4XTableColumn)
    Dim formatter As B4XFormatter
    formatter.Initialize
    c.Formatter = formatter
    Dim Positive As B4XFormatData = c.Formatter.NewFormatData
    Positive.TextColor = xui.Color_blue
    Positive.FormatFont = xui.CreateDefaultFont(16)
    Positive.DecimalPoint = ","
    Positive.GroupingCharacter = "."
    Positive.MinimumFractions = 2
    c.Formatter.AddFormatData(Positive, 0, c.Formatter.MAX_VALUE, True) 'Inclusive (zero included)
    Dim Negative As B4XFormatData = c.Formatter.CopyFormatData(Positive)
    Negative.TextColor = xui.Color_Red
    Negative.FormatFont = xui.CreateDefaultBoldFont(16)
'    Negative.Prefix = "("
'    Negative.Postfix = ")"
    c.Formatter.AddFormatData(Negative,c.Formatter.MIN_VALUE, 0, False)
End Sub

Original refresh sub from B4XTableSelections:
Public Sub Refresh
    For i = 0 To mTable.VisibleRowIds.Size - 1
        Dim clr As Int
        If i Mod 2 = 0 Then clr = mTable.EvenRowColor Else clr = mTable.OddRowColor
        Dim RowId As Long = mTable.VisibleRowIds.Get(i)
        Dim RowSelected As Boolean = SelectedLines.ContainsKey(RowId)
        If RowSelected And LineMode = False Then
            Dim SelectedCells As List = SelectedLines.Get(RowId)
        End If
        For Each col As B4XTableColumn In mTable.VisibleColumns
            Dim p As B4XView = col.CellsLayouts.Get(i + 1)
            Dim lbl As B4XView = p.GetView(col.LabelIndex)
            If RowSelected And (LineMode Or SelectedCells.IndexOf(col.Id) > -1) Then
                p.Color = SelectionColor
                lbl.TextColor = SelectedTextColor
            Else
                p.Color = clr
                lbl.TextColor = mTable.TextColor
            End If
        Next
    Next
    If AutoRemoveInvisibleSelections Then
        Dim RowsToRemove As List
        RowsToRemove.Initialize
        For Each RowId As Long In SelectedLines.Keys
            If mTable.VisibleRowIds.IndexOf(RowId) = -1 Then
                RowsToRemove.Add(RowId)
            End If
        Next
        For Each RowId As Long In RowsToRemove
            SelectedLines.Remove(RowId)
        Next
    End If
End Sub
 
Top