B4J Question Find Form that contain a Node

Discussion in 'B4J Questions' started by Teech, Feb 15, 2019.

Similar threads

B4J Tutorial Accordion container
B4J Tutorial Pagination Container
B4J Tutorial TabPane Example
B4J Tutorial [B4X] Resumable Subs - Sleep / Wait For
B4J Tutorial Customized ListView
  1. Teech

    Teech Member Licensed User

    I have a Layout used in lots of forms and pane, loaded with [container].LoadLayout. In my class i have a Sub like this:
    Code:
    Public Sub LoadLayout(parent As Object,caller As Object)
        mCaller=caller
        
    If parent Is TabPane Then
            
    Dim t As TabPane=parent
            t.LoadLayout(
    "EmployeesList","Employees")
        
    End If
        
    If parent Is Form Then
            
    Dim f As Form= parent
            f.RootPane.LoadLayout(
    "EmployeesList")
        
    End If
        FillEmployeesView
    End Sub
    This Layout (EmployeesList) has a button that show a DirectoryChooser.
    Unfotunatelly i can't find which form is in use to pass as argument in DirectoryChooser.Show.
    Code:
    Sub btCSV_Click
        
    Dim d As DirectoryChooser
        d.Initialize
        d.InitialDirectory=
    File.DirTemp
        
    Dim dir As String   
        dir=d.Show(???) 
    '<--- PROBLEM
       
        
    If dir<>"" Then
          
    'Do Something
        End If
    End Sub
    Could someone help me?
    Many thanks
     
  2. MarkusR

    MarkusR Well-Known Member Licensed User

    does it work with?
    Code:
    d.Show(MainForm)
    d.Show(Main.MainForm)
    Code:
    Sub Process_Globals

        
    Public MainForm As Form

    End Sub
     
  3. Daestrum

    Daestrum Well-Known Member Licensed User

    You could just create a form to use
    Code:
    Sub btCSV_Click
        
    Dim d As DirectoryChooser
        d.Initialize
        d.InitialDirectory=
    File.DirTemp
        
    Dim dir As String
        
    Dim f As Form   ' doesn't even need to be initialized <--- Solution
        dir=d.Show(f) '<--- PROBLEM
       
        
    If dir<>"" Then
          
    'Do Something
        End If
    End Sub
     
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