B4A Library [Class] Flexible Table

dwsands

Member
Licensed User
Longtime User

Thank you!!!!!

Now your probably going to laugh at this question, but the "Main.myFont" gives an "Undeclared variable..." error. The module and the layout are named Main so I'm stuck, help.
 

Kanne

Member
Licensed User
Longtime User
the first parameter is a variable of type Typeface which is declared in my main-module.
You may also use any constant from B4X instead, e.g.
Typeface.SERIF
or
Typeface.SANS_SERIF
.
So the statement may look something like this (for using the font sans_serif with style italic):
B4X:
lbls(i).Typeface = Typeface.CreateNew(Typeface.SANS_SERIF, Typeface.STYLE_ITALIC)
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Attached an example of my app
I don't understand where the specified function is located and where to get its parameters from. Could you give a more detailed example instead of a picture.
 

Kanne

Member
Licensed User
Longtime User
the callback function is called by the table-class when a row is going to be repainted (called only if such a sub exists).
It is located in the module where you are using the table.
The name of the the sub is a the name of your table extend by
The parameters are allways the row which the table is going to paint and the labels themself as an array.
The sub is called before output, so here you may do anything you want with the labels but you should not change the tableformat itself
(e.g. changing column width could result in an endless loop because changing the width would call a repaint of the table !)
Callback function:
Sub Table1_ShowRow(Row As Int, lbls() As Label)
    ' your code here
End Sub
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Kanne,
In my version of Table, the ShowRow method only has one argument: Row As Int
 

Kanne

Member
Licensed User
Longtime User
it is NOT the table function "myTable.ShowRow(...)" but the callback sub "myTable_ShowRow(...)" !
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
I do not understand. Where to get the lbls () parameter?
 

AnandGupta

Expert
Licensed User
Longtime User
Hi @Sergey_New

I think you have not written 'sub' of events earlier. Maybe you have only tried downloaded complete examples.

I suggest to read klaus booklet where he has explained everything.

Regards,

Anand
 

klaus

Expert
Licensed User
Longtime User
Again. You must add a Table.ShowRow event routine in the module where the Table is used.

Something like this:
B4X:
Private Sub Table1_ShowRow(Row As Int, lbls() As Label)
    If Row = 8 Then
        For i = 0 To lbls.Length - 1
            lbls(i).Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD_ITALIC)
        Next
    End If
End Sub

To easily generate an event routine you should have a look at page 64 in the B4X IDE booklet.
 
Last edited:

Sergey_New

Well-Known Member
Licensed User
Longtime User
AnandGupta, Klaus
I can generate an event routine.
I don't understand where to get the lbls () parameter from.
Please write how to call the execution of Table1_ShowRow.
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Attached a simple example. Please supplement it to implement this method.
 

Attachments

  • Test.zip
    19.3 KB · Views: 260

klaus

Expert
Licensed User
Longtime User
You already have it in your test program.
Every time a row is shown in the Table class this event is called.
In the event routine in your example the TypeFace of row 3 is changed.
You need to enter the code for each row where you want to change something.

Or explain exactly what you want to do.
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
klaus,
I want the text on line 3 to be italic.
This is not shown in the screenshot.
 

klaus

Expert
Licensed User
Longtime User
When I looked at your project I was not aware that you are using version 1.43 a very very old version.
I updated with version 3.26.
In this version the Table is added in the Deisgner.

 

Attachments

  • TestNew.zip
    37.7 KB · Views: 240

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thank you Klaus! Now everything is OK!
 

dwsands

Member
Licensed User
Longtime User
I cannot get SetTextColors to work in the table. In the code below the SetColumnColors works fine but even though SetTextColors has the same syntax it has no effect. Any ideas?

B4X:
Table1.SetColumnColors(Array As Int(Colors.RGB(255, 0, 0), Colors.RGB(191, 245, 229), Colors.RGB(255, 228, 165)))
Table1.SetTextColors(Array As Int(Colors.RGB(0, 0, 255), Colors.RGB(0, 0, 255), Colors.RGB(0, 0, 255)))
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…