B4J Question Table View Auto resize column to content

riaanp

Member
Good Day Fellow B4J Users,

I was wondering if anyone has a generic sub routine that can auto resize the columns to match the content size per row if that makes sense? I have been searching the forums and found a few code examples. But not sure how to implement. So was wondering if someone made a generic routine and be willing to share?
 

riaanp

Member
Btw: this is my old VB6 code that auto sized grids (tables) - found this years ago somewhere and modified it a bit. Might be help full to someone to try and make this work using B4J


B4X:
Public Sub ResizeGridX(pGrid As MSHFlexGrid, pForm As Form)

        Dim intRow As Integer
        Dim intCol As Integer
       
        'for empty rows
        Dim i As Integer
        Dim j As Integer
        Dim sSQL As String
     
        With pGrid
            For intCol = 0 To .Cols - 1
                For intRow = 0 To .Rows - 1
                    If .ColWidth(intCol) < pForm.TextWidth(.TextMatrix(intRow, intCol)) + 100 Then
                      .ColWidth(intCol) = pForm.TextWidth(.TextMatrix(intRow, intCol)) + 100
                    End If
                Next
            Next
        End With
 
Upvote 0
Top