Bug? Problem with TableView add from variable.

Discussion in 'B4J Bugs & Wishlist' started by Gary Miyakawa, May 8, 2015.

  1. Gary Miyakawa

    Gary Miyakawa Active Member Licensed User

    This one is odd (or, I just don't understand).

    I've built a small 2 column (default) tableview. I then add 3 items to it from an array. That array of elements was created from a Regex split. If I add the items directly from the split, All is good BUT if I move the values of those items to another matching string array, only the last value gets added to all the rows in the Tableview.

    Code:
    TableView1.SetColumns(Array As String("Site Name""IP Address"))
        line = 
    "HDX Desk"", ""10.1.2.86:24""" & CRLF & "Group Series"", ""10.1.2.50:24""" & CRLF & "Callback 157"", ""171.1.2.157:24""" & CRLF

        lines = 
    Regex.Split(CRLF, line)            'Split the lines based on CRLF

        
    For Each item In lines
             items = 
    Regex.Split(",", item)        'Split the line based on Comma
            test(0) = items(0)                    'move value from one array to another
            Log("Added: " & test(0))            'Show it's value in the log
       
            test(
    1) = items(1)
            
    Log("Added: " & test(1))
           
            TableView1.Items.Add(test)            
    'add the 'test' string array to the tableview
        Next
    I have my get around but I'm trying to understand if this is a BUG or a misunderstanding on my part.

    I've included the .zip of the application.

    Anyone that can help me understand this would be greatly appreciated.

    Gary Miyakawa
     

    Attached Files:

    • TTV.zip
      File size:
      1.4 KB
      Views:
      20
  2. rwblinn

    rwblinn Well-Known Member Licensed User

    Hi,

    for every row you need to use a new array. Try:

    Code:
    For Each item In lines
      
    Dim row(2As String
      row = 
    Regex.Split(",", item)        'Split the line based on Comma
      TableView1.Items.Add(row)         'Add the string array to the tableview
    Next
    One other. You could simplify the string:
    Code:
    line = "HDX Desk,10.1.2.86:24" & CRLF & "Group Series,10.1.2.50:24" & CRLF & "Callback 157,171.1.2.157:24"
     
  3. Gary Miyakawa

    Gary Miyakawa Active Member Licensed User

    Thank you for the reply.

    Your solution still doesn't allow me to move the value to the new array (in my case, it's called "test".)... I still get the repetitive issue.

    As for simplifying the string, It needs to meet .csv format (which includes the Double quotes around text fields) so that is not an option.

    Thank you though !

    Gary Miyakawa
     
  4. Daestrum

    Daestrum Well-Known Member Licensed User

    Try
    Code:
    For Each item In lines
            items = 
    Regex.Split(",", item)        'Split the line based on Comma
            Dim test(2As String
            test(
    0) = items(0)
            test(
    1) = items(1)
            
    Log("Added: " & test(0))            'Show it's value in the log
            Log("Added: " & test(1))
            TableView1.Items.Add(test)            
    'add the 'test' string array to the tableview
        Next
     
  5. Gary Miyakawa

    Gary Miyakawa Active Member Licensed User


    Thank you! Yes, that does work and fix the issue but Why does the array have to be redefined each time ?

    Thanks!

    Gary Miyakawa
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. Gary Miyakawa

    Gary Miyakawa Active Member Licensed User

    Thank you Erel!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice