B4J Question Get Pane- Tab Control

Discussion in 'B4J Questions' started by ykucuk, Jul 15, 2019.

  1. ykucuk

    ykucuk Well-Known Member Licensed User

    Hello,

    How can I access to the pane in the Tab Page?

    is there similar with
    Code:
    GetAllViewsRecursive
    ?
     
  2. jmon

    jmon Well-Known Member Licensed User

    Hi,

    Yes you can do it like that (Need JavaObject):

    Code:
    Sub GetTabPanePages(Target As TabPaneAs List
        
    Dim joTarget As JavaObject = Target
        
    Return joTarget.RunMethod("getTabs"Null)
    End Sub
    Code:
    For Each v As TabPage In GetTabPanePages(tp)
     
    Log(v.Text)
    Next
     
  3. ykucuk

    ykucuk Well-Known Member Licensed User

    Thanks for the reply but exactly I asked about how to access Pane in the second Tab Page in the tab control.
     
  4. DonManfred

    DonManfred Expert Licensed User

    No one is stopping you from using a counter in the loop
    Code:
    dim counter as int = 0
    For Each v As TabPage In GetTabPanePages(tp)
      
    if counter=1 then
         
    Log(v.Text)
      
    end if
     counter = counter+
    1
    Next
     
    jmon likes this.
  5. jmon

    jmon Well-Known Member Licensed User

    Hi, you can do it like that, Like DonManFred said:
    Code:
    Dim count As Int = 0
    For Each p As TabPage In tp.Tabs
        
    If count = 1 Then
            
    Dim btn As Button
            btn.Initialize(
    "")
            btn.Text = 
    $"Button added to page 2!"$       
            p.Content.AddNode(btn, 
    5050200100)
        
    End If   
        count = count + 
    1
    Next
    tp.SelectedIndex = 
    1
    Here that creates a button on the second page (page index 1, because the first page is index 0). So the pane of the TabPage is accessed via "p.Content".

    By the way, I don't know why I went as far as using JavaObject in the first example, but to access the tabs, just use:
    Code:
    tp.Tabs
    Instead of the code I wrote above o_O
     
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