B4J Tutorial TableView Tutorial

Discussion in 'B4J Tutorials' started by Erel, Dec 10, 2013.

  1. electro179

    electro179 Active Member Licensed User

    Hi

    can I add col with scene builder and not use items.add(array.......)

    I used with only scene builder but it does not work

    Code:
    Dim row(6As Object
      
        row(
    0) = "TEST 1"
        row(
    1) = "TEST 1"
        row(
    2) = "TEST 1"
        row(
    3) = "TEST 1"
        row(
    4) = "TEST 1"
        row(
    5) = "TEST 1"
        TableView_cabinet.Items.Add(row)

    all line is empty


    thank you
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    No. You need to add the columns with TableView.SetColumns.
     
  3. CHAUVET

    CHAUVET Member Licensed User

    hello,

    In a tableView how can we add an image in a cell?

    thank you,
     
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. CHAUVET

    CHAUVET Member Licensed User

    Hello Erel.
    It's OK !

    Code:
    Private pictoImage As ImageView
    Private tableView1 As TableView
    Code:
    Dim img_http As Image
    img_http.Initialize(
    File.DirAssets,"http.png")
                 
    Dim row(2As Object
    pictoImage.Initialize(
    "ImageView")
    pictoImage.SetImage(img_http)
                 
    row(
    0) = pictoImage
    row(
    1) = "File -> http.png"

    tableView1.Items.Add(row)
     
  6. tdocs2

    tdocs2 Well-Known Member Licensed User

    Greetings.

    Newbie question....

    I could not find a Member for Number_of_Rows in the Tableview. For example,

    Code:
    For I =0 to Tableview1.NumberRows -1
    Obviously, I missed a basic block...

    Thank you for your help.

    Sandy
     
  7. Roycefer

    Roycefer Well-Known Member Licensed User

    Use
    Code:
    For i = 0 to Tableview1.Items.Size-1
    '.....
     
    tdocs2 likes this.
  8. tdocs2

    tdocs2 Well-Known Member Licensed User

    Me - NEWBIE!!!!!!!!!!!!!!!

    Thank you, Roycefer.

    Sandy
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Another option:
    Code:
    For Each row() As Object in TableView.Items

    Next
     
    tdocs2 likes this.
  10. raphipps2002

    raphipps2002 Active Member Licensed User

    If this selects a row

    jo.RunMethodJO("getSelectionModel",Null).RunMethod("select",Array(j))

    How can one DEselect a row?

    :)
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    You can call clearSelection instead of select.
     
  12. IslandMedic

    IslandMedic Member Licensed User

    I want to use a table view for showing incoming message from the server. It seems like a good tool to use, has alot of formatting controls etc all built in. Here is my code and here arey questions.


    Code:
    'setup the table view for messaging 
        OpTableView1.SetColumns(Array As String("Time","Sender","Message"))
        OpTableView1.SetColumnSortable(
    0,True)  'can sort by time
        OpTableView1.SetColumnSortable(1,True)  'can sort by sender
        OpTableView1.SetColumnSortable(2,False)  'cannot sort by message
        OpTableView1.SetColumnWidth(0,60'fixes the time column width.
        OpTableView1.SetColumnWidth(0,100'fixes the time column width.

    Public Sub WriteMsg(msg As String,from As String)
        
    Dim row(3As Object
        row(
    0) = DateTime.Time(DateTime.Now)
        row(
    1) = from
        row(
    2) = msg
           
        
    'add the new items
        OpTableView1.Items.Add(row)
       
    'sort the time column to put the newest message at the top.
       
    End Sub
    1. I want the new message to be at the top of the view. I know I can sort the column by clicking on the header, but can I do it in code? So what I would do is insert the row and then get it to sort by time for the user so the newest message is always at the top.

    2. I only want to have three columns, so doing this OpTableView1.SetColumnVisible(3) etc doesn't seem practical, how would I just have three?

    3. the third column it would be nice to have the size of it be the remaining percentage of the table view window.

    thanks in advance,

    Brad
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for these questions.
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    The example in the first thread was updated. The layout is now done with the internal designer. All the cells are made of labels and there are helper methods to make it simple to get and set the cells values.
     
    rbghongade likes this.
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