B4J Question listview or gridview

raphipps2002

Active Member
Licensed User
Longtime User
As vb.net developer am new to B4J...call me a novice

I want to create a table with colums and plunged into thinking i should use a listview similar to vb.net. However it seems that this is a single column object

So, how do I create a table with columns and rows
 

raphipps2002

Active Member
Licensed User
Longtime User
Ah I see...so successfully added rows to my 5 column table, one by one....I wanted to add up one particular column. But Dim r() As String = tblCB.Items.Get(j) causes a crash.

B4X:
For j  = 0 To tblCB.Items.Size-1
  
       Dim r() As String = tblCB.Items.Get(j)
        
        BankOut = BankOut + r(2)
      
        BankIn = BankIn + r(3)
              
    Next

What am I doing wrong?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
What is the actual error message you are getting ?
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
What is the stack trace for the crash? There could be any of a number of possible problems. You might be trying to access an empty array element. You might be trying to cast a String to a numerical type and the cast is failing. But this is all just wild speculation without seeing the stack trace.
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
As I got your message i found this on the, dim r() as object = tb.items.get(j)

The object worked not string...thanks anyway
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
As a tip. if you have 5 columns, create a type variable so you can refer to the columns by name
ie.
B4X:
Type datarow (a as object, b as object, bankOut as object, bankIn as object, e as object)
then your code becomes
B4X:
    ...
    Dim row As datarow = tblCB.Items.Get(j)
    BankOut = BankOut + row.bankOut
    BankIn = BankIn + row.bankIn
...
which is easier to read and less prone to adding the wrong column to your totals etc
 
Upvote 0
Top