B4J Question B4XTable GridColor is not always working

aeric

Expert
Licensed User
Longtime User
I have set the GridColor to Transparent but the grid line is still showing, but some columns are working.
B4X:
B4XTable1.GridColor = xui.Color_Transparent

or is there a way to make the grid width smaller?

1686245666866.png
 

Mahares

Expert
Licensed User
Longtime User
This works for me. I hope it works for you if nobody can give you a simpler and a more obvious solution.
B4X:
Sub B4XTable1_DataUpdated
    For row = 0 To B4XTable1.VisibleRowIds.Size - 1
        For Each col As B4XTableColumn In B4XTable1.Columns
            Dim pnl As B4XView = col.CellsLayouts.Get(row)
            If row = 0 Then
                pnl.SetColorAndBorder(xui.Color_Gray, 0dip, xui.Color_Transparent, 0dip)
            Else
                Dim background As Int = IIf(row Mod 2 = 0, B4XTable1.EvenRowColor, B4XTable1.OddRowColor)
                pnl.SetColorAndBorder(background, 0dip, xui.Color_transparent, 0dip)
            End If
        Next
    Next
End Sub
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
This works for me. I hope it works for you if nobody can give you a simpler and a more obvious solution.
B4X:
Sub B4XTable1_DataUpdated
    For row = 0 To B4XTable1.VisibleRowIds.Size - 1
        For Each col As B4XTableColumn In B4XTable1.Columns
            Dim pnl As B4XView = col.CellsLayouts.Get(row)
            If row = 0 Then
                pnl.SetColorAndBorder(xui.Color_Gray, 0dip, xui.Color_Transparent, 0dip)
            Else
                Dim background As Int = IIf(row Mod 2 = 0, B4XTable1.EvenRowColor, B4XTable1.OddRowColor)
                pnl.SetColorAndBorder(background, 0dip, xui.Color_transparent, 0dip)
            End If
        Next
    Next
End Sub

The last row is not applied but still the vertical grid lines sometimes not working.

1686291656311.png
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
The position of the gridcolor setting in your code seems to matter (before filling the table).
B4X:
    B4XTbl1.Clear
    B4XTbl1.GridColor = xui.Color_Transparent
View attachment 142785
Yes, I have followed this.
I am not sure because my layout is a bit complicated (with some transparent background panels and colored headers).
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I have even modified the source code of B4XTable.bas

B4X:
#DesignerProperty: Key: GridColor, DisplayName: Grid Color, FieldType: Color, DefaultValue: 0x00FFFFFF

Line #649:
p.SetColorAndBorder(clr, 0, GridColor, 0)
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I found something interesting.

If I don't set the column's width, the thin lines appear.
If I set something like 150dip, the line does not appear. If I change the column width to 180dip, the line appears.

In another table, if I don't set the column's width, the thin lines does not appear.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I think this is issue with OS deal with resolutions.
When I tried change the resolution to low settings such as 1024x768, the lines are not visible.
Windows 11 is really buggy. :confused:
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I will try play around
I forgot that you are working in B4J environment. Here is an extensive testing in B4J. It seems to be working as desired. No gridlines on the header and no gridlines in data rows. Please do me a favor and test it in your B4J even if you decide to abandon the idea:
Place this code after you define the columns:
B4X:
For Each col As B4XTableColumn In B4XTable1.Columns
        Dim pnl As B4XView = col.CellsLayouts.Get(0)
        pnl.SetColorAndBorder(xui.Color_Gray, 0dip, xui.Color_Transparent, 0dip)
    Next

B4X:
Sub B4XTable1_DataUpdated
    For row = 0 To B4XTable1.VisibleRowIds.Size - 1
        For Each col As B4XTableColumn In B4XTable1.Columns
            Dim pnl As B4XView = col.CellsLayouts.Get(row+1)
            Dim background As Int = IIf(row Mod 2 = 0, B4XTable1.EvenRowColor, B4XTable1.OddRowColor)            
            pnl.SetColorAndBorder(background, 0dip, xui.Color_transparent, 0dip)                
        Next
    Next
End Sub
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I forgot that you are working in B4J environment. Here is an extensive testing in B4J. It seems to be working as desired. No gridlines on the header and no gridlines in data rows. Please do me a favor and test it in your B4J even if you decide to abandon the idea:
Place this code after you define the columns:
B4X:
For Each col As B4XTableColumn In B4XTable1.Columns
        Dim pnl As B4XView = col.CellsLayouts.Get(0)
        pnl.SetColorAndBorder(xui.Color_Gray, 0dip, xui.Color_Transparent, 0dip)
    Next

B4X:
Sub B4XTable1_DataUpdated
    For row = 0 To B4XTable1.VisibleRowIds.Size - 1
        For Each col As B4XTableColumn In B4XTable1.Columns
            Dim pnl As B4XView = col.CellsLayouts.Get(row+1)
            Dim background As Int = IIf(row Mod 2 = 0, B4XTable1.EvenRowColor, B4XTable1.OddRowColor)           
            pnl.SetColorAndBorder(background, 0dip, xui.Color_transparent, 0dip)               
        Next
    Next
End Sub
I have tested your code above. It seems the behaviour is the same.
I believe this happen in my Windows with wide screen display and high resolution (1920 x 1080).
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I have tested your code above. It seems the behaviour is the same.
One way to find out is if you export a small project without disclosing sensitive data that shows the problem on your computer and we can test it for you with the code I posted in post #10. I have tested it extensively in B4J and B4A and with several databases and apps. It worked the way it is supposed to every time. I even tested it with a table that has 11 columns.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
One way to find out is if you export a small project without disclosing sensitive data that shows the problem on your computer and we can test it for you with the code I posted in post #10. I have tested it extensively in B4J and B4A and with several databases and apps. It worked the way it is supposed to every time. I even tested it with a table that has 11 columns.
I believe this happen in my Windows with wide screen display and high resolution (1920 x 1080).
Have you tested with different screen resolution?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Have you tested with different screen resolution?

Yes, tested on these resolutions on PC 1920x1080 and also 1289x1024. I also tested it on a samsung phone with: 2280x1080. Worked fine. That is why you need to export a sample project so members can test it for you at whatever resolution they have. If you can't, good luck.
1686327444160.png
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Yes, tested on these resolutions on PC 1920x1080 and also 1289x1024. I also tested it on a samsung phone with: 2280x1080. Worked fine. That is why you need to export a sample project so members can test it for you at whatever resolution they have. If you can't, good luck.
View attachment 142814
I will try to create one but I am strongly believe that it is my PC problem.
 
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
On "old" Android 8.1.0 API level 27:
The grid lines show up!
1687410942940.png

On "old" Windows 10 version 1511:
The grid lines do NOT show up! (even after resizing)
1687411054705.png

Maybe this is OS related... or Java related... or ???
 

Attachments

  • B4A_B4XTableGridLines.zip
    11.1 KB · Views: 78
  • B4J_B4XTableGridLines.zip
    4 KB · Views: 76
Upvote 0

aeric

Expert
Licensed User
Longtime User
I added some code to your project. Here is attached the B4X project. You can run it in either B4A ( tested on OS 8.1 and OS 11) or B4J ( tested on a PC). The code removes all gridlines. All works for me as expected. This is as far as I am going with this. If that is not what you want, just toss it.
Thanks for trying out.
As I am writing in B4J forum, I am more concern on Windows platform. I will try your project later.
 
Upvote 0
Top