Android Question Resize Columns According to Content inside the cell column of B4X Table

RishiKumar2210

Active Member
I need to resize the height of cell column of b4x table according to content inside the cell column. Is this Possible?
 

zed

Active Member
Licensed User
The solution is just below
 
Upvote 0

RishiKumar2210

Active Member
Sorry, I need to resize the height of particular column. But The above link use to resize the width of particular column
 
Upvote 0

zed

Active Member
Licensed User
Houps!

1 : Use measureMultilineTextheight from stringUtils library
2 : B4XTable.RowHeight = yourValue.dip - Set it before adding the data.
 
Upvote 0

RishiKumar2210

Active Member
Houps!

1 : Use measureMultilineTextheight from stringUtils library
2 : B4XTable.RowHeight = yourValue.dip - Set it before adding the data.
If I use B4XTable.RowHeight = yourValue.dip it resize all rows heights. But I need to resize a particular row according to content inside the column.

Is it Possible?
 
Upvote 0

RishiKumar2210

Active Member
I do not think you can adjust the height of only one given row in the table. based on the B4XTable code. Maybe if you modify the code. I tried for quite a while unsuccessfully. However, if I am mistaken Erel will straighten us out.
What Changes I need to made in my code or is this impossible?
 
Upvote 0

zed

Active Member
Licensed User
It is not one line that needs to be modified, but the entire code.
B4XTable is based on a CLV.
If you change the height of the lines in a CLV, all the lines will be increased. It is therefore not possible to modify the height of a single line.
There might be other alternatives, but we don't know what you want to do.
Explain your project a little and post the code that is causing you problems
 
Upvote 0

RishiKumar2210

Active Member
I have b4x table with 5 columns and I have nearly 1000 rows. I have a column called "Company Name". In this column I have a companyname morethan 300 characters. For Example SRE KAMAKCHI SILKS-T.KALLUPATTI ( Rec No : C/8 By Cash From SRE KAMAKCHI SILKS - T.KALLUPATTI)

So I have to resize the HEIGHT(Not Width) of column according to content in the column.
 
Upvote 0

zed

Active Member
Licensed User
For example, you could reduce the company name when displaying and clicking on the column opens a popup with full contact details.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I have b4x table with 5 columns and I have nearly 1000 rows. I have a column called "Company Name
Here is one way you can approach it by reducing the font size when the textt length is above a certain number of characters (see screenshot): Please note that c1 is your column 'Company Name' and declared in Globals: Private c1 As B4XTableColumn
B4X:
Sub B4XTable1_DataUpdated
    Dim f As B4XFont =B4XTable1.LabelsFont
    For i = 0 To B4XTable1.VisibleRowIds.Size - 1
        Dim p As B4XView = c1.CellsLayouts.Get(i+1)
        Dim b4xlbl As B4XView= p.GetView(0)
        If b4xlbl.Text.Length > 30 Then
            b4xlbl.Font = xui.CreateDefaultFont(12)  'adjust your font accordingly
        Else
            b4xlbl.Font = f
        End If
    Next
End Sub
 
Reactions: zed
Upvote 0

RishiKumar2210

Active Member
I Tried this But the Text has not fit to the column. Some texts are hidden inside the columns.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…