B4J Code Snippet B4XTable Column Resizing... (works for me)

Magma

Expert
Licensed User
Longtime User
...Found a little bug - please replace this sub:
B4X:
Private Sub hhheaderpanel_MouseReleased (EventData As MouseEvent)
    If headerpressing=True Then
        
'        Log("size it")
        Dim pane1 As B4XView=Sender
        If pane1.IsInitialized Then
            headerpressing=False
            Dim cc1 As B4XTableColumn=B4XTable1.visibleColumns.Get(pane1.tag)
            'lets count some things
            Dim beforesize As Int=cc1.Width
            Dim fromleftsize As Int
            Dim newsize As Int
            For k=0 To pane1.tag-1
                Dim cc As B4XTableColumn=B4XTable1.visibleColumns.Get(k)
                fromleftsize=fromleftsize+cc.Width
            Next
            newsize=cc1.Width
            If pane1.Left<B4XTable1.mBase.Left+fromleftsize Then   'added that... last column width check... the .left goes into the other columns .. with that limit it !
                pane1.left=B4XTable1.mBase.Left+fromleftsize+1
                newsize=1
            End If
            If pane1.Left>beforesize Then
                newsize=(pane1.left-B4XTable1.mBase.Left)-fromleftsize
            Else
                If pane1.Left>B4XTable1.mBase.Left+fromleftsize Then
                    newsize=(pane1.left-B4XTable1.mBase.Left)-fromleftsize
                Else
                    pane1.Left=fromleftsize+cc1.Width
                End If
            End If
            cc1.Width=newsize
            B4XTable1.Refresh
            Sleep(0)
            enableresize
            B4XTableTimer.Enabled=True
        End If
        
    End If
    
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…