B4J Question How to draw lines on a table in VisualDesigner?

daiweisc

Member
How to draw lines on a table in VisualDesigner?
2023-05-03_072905.png
 

Attachments

  • 2023-05-03_072905.png
    2023-05-03_072905.png
    30.7 KB · Views: 48

mcqueccu

Well-Known Member
Licensed User
Longtime User
As Erel said, this looks like a list so Customlistview or B4Xtable will be the ideal.

Apart from that, this is what I do if I just need a single line under a Heading or an item.
I add a label and set its height to 1. Then fill the label with the color I want
 
Upvote 0

daiweisc

Member
Thanks for reply.
If I need two Customlistviews loaded from two SQLs in one page, how to write the code?
Can you give a example.
 
Last edited:
Upvote 0

daiweisc

Member
Two data tables are attached.
Table1


DN/mmdi/mm
20
19​
21.1​
25
26​
27.3​
40
38​
41.1​
50
50​
52.3​
80
81​
77.7​
100
100​
101.7​
150
150​
154.1​
200
207​
203.1​
250
257​
255.4​
300
309​
303.9​
350
359​
333.6​
400
406​
381.4​
450
458​
428.6​
500
506​
476​

Table2


管子类型等值粗糙度(mm)
不锈钢无缝钢管和不锈钢焊接钢管0.1
无缝钢管0.2
焊接钢管0.2
高腐蚀运行条件下的钢管(排汽管、溢流管)0.55~0.65
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Each row of pipe Dn includes Di and De, using CLV is the best choice
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
As Erel said, this looks like a list so Customlistview or B4Xtable will be the ideal.

Apart from that, this is what I do if I just need a single line under a Heading or an item.
I add a label and set its height to 1. Then fill the label with the color I want
I do the same
 
Upvote 0

daiweisc

Member
Why the code run wrong?
The Whole code attach.
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    
    Public SQL1 As SQL
    Private NumberColumn As B4XTableColumn
    
    Private B4XTable1 As B4XTable
    'Private tblData2 As B4XTable
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Table1")
    
    'create the columns
    B4XTable1.AddColumn("DN/mm", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Di/mm", B4XTable1.COLUMN_TYPE_TEXT)
    
    Private ResultSet1 As ResultSet
    ResultSet1 = SQL1.ExecQuery("SELECT rowid FROM Pipe data")
    Dim data As List
    data.Initialize
    Dim rs As ResultSet = SQL1.ExecQuery(ResultSet1)
    Do While rs.NextRow
        Dim row(2) As Object
        row(0) = rs.GetString("DN/mm")
        row(1) = rs.GetString("Di/mm")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
End Sub

And the log is :
B4X:
B4XMainPage - 167: Not all code paths return a value. (warning #2)
Table1 - 31: Object converted to String. This is probably a programming mistake. (warning #7)
Table1 - 6: Variable 'NumberColumn' is never assigned any value. (warning #10)
File 'Pipe data.db' is not used. (warning #15)

1683184357929.png
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Private ResultSet1 As ResultSet
ResultSet1 = SQL1.ExecQuery("SELECT rowid FROM Pipe data")
Dim data As List
data.Initialize
Dim rs As ResultSet = SQL1.ExecQuery(ResultSet1)
Do While rs.NextRow
Dim row(2) As Object
row(0) = rs.GetString("DN/mm")
row(1) = rs.GetString("Di/mm")
data.Add(row)
You'd better post a small project.

The ResultSet you only selected a field rowid, and how you could get DN and Di?
 
Upvote 0

daiweisc

Member
Thsnks for reply.
The code run wrong. I guess the 26 line code is the problem.
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    
    Public SQL1 As SQL   
    Private B4XTable1 As B4XTable
    'Private tblData2 As B4XTable
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Table1")
    
    'create the columns
    B4XTable1.AddColumn("DN/mm", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Di/mm", B4XTable1.COLUMN_TYPE_TEXT)
    
    Private ResultSet1 As ResultSet
    ResultSet1 = SQL1.ExecQuery("SELECT * FROM Pipe data")
    Dim data As List
    data.Initialize
    Dim rs As ResultSet = SQL1.ExecQuery(ResultSet1)
    Do While rs.NextRow
        Dim row(3) As Object
        row(0) = rs.GetString("ID")
        row(1) = rs.GetString("DN/mm")
        row(2) = rs.GetString("Di/mm")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
End Sub
 
Upvote 0
Top