RishiKumar2210
Active Member
i have type a text inside a row of b4x table like column(2) = "total". but i need to make this text as bold. is it possible?
It is not clear from your question what text you wanted to make bold (data?, header?). You need to enter some code show a snapshot of of the table part that is supposed to be bold.i have type a text inside a row of b4x table like column(2) = "total". but i need to make this text as bold. is it possible?
If you want to make the entire column bold, you can use this code (courtesy Mahare's answer in forum):i have type a text inside a row of b4x table like column(2) = "total". but i need to make this text as bold. is it possible?
I use this in my b4xtable:
'neetmarks = tbl1.AddColumn("NEET MARKS", tbl1.COLUMN_TYPE_NUMBERS)
Dim c As B4XTableColumn= neetmarks
For i = 1 To c.CellsLayouts.Size - 1
Dim pnl As B4XView = c.CellsLayouts.Get(i)
Dim lbl As B4XView = pnl.GetView(0)
lbl.Font = xui.CreateDefaultBoldFont(20)
Next
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Dim c1 As B4XTableColumn = B4XTable1.AddColumn("Col 1", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Col 2", B4XTable1.COLUMN_TYPE_NUMBERS)
Dim data As List
data.Initialize
For i = 1 To 100
data.Add(Array("Item #" & i, i))
Next
B4XTable1.MaximumRowsPerPage = 20
B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
For i = 1 To c1.CellsLayouts.Size - 1 'skipping the header
Dim pnl As B4XView = c1.CellsLayouts.Get(i)
pnl.GetView(c1.LabelIndex).Font = xui.CreateDefaultBoldFont(16)
Next
B4XTable1.SetData(data)
End Sub
Full code to set entire column:
B4X:Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("MainPage") Dim c1 As B4XTableColumn = B4XTable1.AddColumn("Col 1", B4XTable1.COLUMN_TYPE_TEXT) B4XTable1.AddColumn("Col 2", B4XTable1.COLUMN_TYPE_NUMBERS) Dim data As List data.Initialize For i = 1 To 100 data.Add(Array("Item #" & i, i)) Next B4XTable1.MaximumRowsPerPage = 20 B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage) For i = 1 To c1.CellsLayouts.Size - 1 'skipping the header Dim pnl As B4XView = c1.CellsLayouts.Get(i) pnl.GetView(c1.LabelIndex).Font = xui.CreateDefaultBoldFont(16) Next B4XTable1.SetData(data) End Sub
If you have a table made of a single page then you can make a specific row bold easily. If more than one page then you need to handle the DataUpdated event and change the style there.
You can have something like this:I need to make the text "total" only as bold and no need to bold any other text
Private c1 As B4XTableColumn 'in Class_Global
c1 = B4XTable1.AddColumn("Account Name", B4XTable1.COLUMN_TYPE_TEXT) ' in B4XPage_Created
Sub B4XTable1_DataUpdated
For i = 0 To B4XTable1.VisibleRowIds.Size - 1
Dim pnl As B4XView = c1.CellsLayouts.Get(i+1)
If pnl.GetView(c1.LabelIndex).Text="Total" Then
' If pnl.GetView(c1.LabelIndex).Text.Contains("Total") Then
pnl.GetView(c1.LabelIndex).Font = xui.CreateDefaultBoldFont(32)
Else
pnl.GetView(c1.LabelIndex).Font = xui.CreateDefaultFont(16)
End If
Next
End Sub
It Worked. Thanks Mr. Mahares.You can have something like this:
B4X:Private c1 As B4XTableColumn 'in Class_Global
B4X:c1 = B4XTable1.AddColumn("Account Name", B4XTable1.COLUMN_TYPE_TEXT) ' in B4XPage_Created
B4X:Sub B4XTable1_DataUpdated For i = 0 To B4XTable1.VisibleRowIds.Size - 1 Dim pnl As B4XView = c1.CellsLayouts.Get(i+1) If pnl.GetView(c1.LabelIndex).Text="Total" Then ' If pnl.GetView(c1.LabelIndex).Text.Contains("Total") Then pnl.GetView(c1.LabelIndex).Font = xui.CreateDefaultBoldFont(32) Else pnl.GetView(c1.LabelIndex).Font = xui.CreateDefaultFont(16) End If Next End Sub
Can I able to convert the the text "total" and number in nearby column As bold?. Please Note the number in nearby column is not entered , it is the total of all rows in the debit column.I need to make the text "total" only as bold and no need to bold any other text
Yes, For the total value (number) keep track of a global variable of the sum and use B4XFormatter to format the total value.Can I able to convert the the text "total" and number in nearby column As bold
Private Sub CreateCustomFormat (c As B4XTableColumn)
'code to add the formatter
End sub
B4XTable1.SetData(data)
CreateCustomFormat (B4XTable1.GetColumn("Debit Amount"))