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

Hi there...

Well many of us need/asking column resizing... but noone do the start... well I ve decided to start... but hey... need help.. I think is a good start... need a lot of fixes and your ideas...

I am uploading an example - and give you my notes here...

What works....
- Resizing Columns... smooth (in Release mode)
- Works only with columns had set their width, no auto-resize !!! Caution.
- When Resizing form works ok...
- Double-Click guideline hide column (width 1pixel)... double click again... restore width !!!

What not works...
- No with autoresizing columns / auto-width
- No for the moment with changed order columns
- When using scrollbar loosing the coordinates - you must go back...

(no b4xtable scrollbar event to check, a fix you can do is using timer and call every 500ms the enableresize, didn;t try it but i think will work)
Thanks to LucaMs !! ... :) fixed that too

What not tried...
- At B4A, B4I... please check them

My programming mistakes..
- Can't understand so good the b4xview and adding at root new items... so removefromview has errors... please fix it and tell me the way...
Erel told me the way ! :)

Here a Video to see - how works... old-video now all working !


Is totally open-source - and ofcourse you can always donate me and B4X too.. Please share your code too... to make b4xtable stronger !

Credits to: Erel, LucaMs, Mahares, aeric...

⭐ You can donate me (buy me a coffee, drink, etc) If you think I've helped you...
 

Attachments

  • B4XTableExample-column-resizing-NEW2.zip
    55.7 KB · Views: 117
  • AnimationDONATE.gif
    AnimationDONATE.gif
    10.7 KB · Views: 71
  • AnimationDONATE2.gif
    AnimationDONATE2.gif
    10.8 KB · Views: 7,424
Last edited:

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
 
Top