» »

vb.net: zapri vse tabcontrole

vb.net: zapri vse tabcontrole

klemenSLO ::

V VB.netu bi rad napisal SUB, kateri skrije vse instance tabcontrol-ov na formi.
Poskušal sem takole pa ne gre :
Sub tab_zapre()
        Dim tab As System.Windows.Forms.TabControl
        For Each tab In Me.Controls
            tab.Visible = False
        Next tab
    End Sub


pri vrstici for each tab javi:
Unable to cast object of type 'System.Windows.Forms.SplitContainer' to type 'System.Windows.Forms.TabControl'.
Life is not measured in minutes, but in MOMENTS...

klemenSLO ::

Pa še tole:
Forma vsebuje splitcontainer. TAbi se poavljajo na splitcontainer.panel2
Life is not measured in minutes, but in MOMENTS...

nightrage ::

Poiskus takole:

 Sub tab_zapre() 
       Control control = Nothing     
       For Each control In Me.Controls
          if (control == typeof(System.Windows.Forms.TabControl)) then   
            control.Visible = False
        Next tab
    End Sub 

klemenSLO ::

Če zlistam vse obstoječe controle med njimi ni gumbov in taba.
vrne recimo splitcontainer,statusstrip...

Dejnsko so gumbi na splitcontainerju. Kako bi dostopal do tega? Splitcontainer ima haschildren = true
Life is not measured in minutes, but in MOMENTS...

nightrage ::

Ja potem pol pa nared vgezdeno zanko al pa če greš rekurzivno čez vse kontrole, poiščeš TabControle in jim daš visible na false.

  Sub tab_zapre()
      Control control = Nothing    
      For Each control In Me.Controls
        if (control == typeof("splitcontainer")) then
           Control control1 = Nothing 
           For Each control1 In control.Controls
             if (control == typeof(System.Windows.Forms.TabControl)) then  
               control.Visible = False
           Next tab
       Next tab
  End Sub

klemenSLO ::

No pa sm sestavu. Ni optimalno vendar dela. So pa trije nivoji
(0)Forma:
(1)---SplitCOntainer
(2)-----splitpanel
(3)-------tabcontrol

For Each ctl As Control In Controls

            If ctl.HasChildren = True Then
                For Each chd As Control In ctl.Controls

                     If TypeOf (chd) Is TabControl Then
                        chd.visible = false
                        If chd.HasChildren = True Then
                            For Each chd2 As Control In chd.Controls
                                If TypeOf (chd2) Is TabControl Then
                                    chd2.Visible = False
                                End If
                            Next
                        End If
                    End If
                Next chd       
            End If        
  Next ctl
Life is not measured in minutes, but in MOMENTS...

Zgodovina sprememb…

Spura ::

Lahko preprosto napises rekurzivno funkcijo, ki ti preisce vse komponente poljubno globoko in ti vrne vse komponente dolocenega tipa.


Druga stvar:

If TypeOf (chd) Is TabControl Then
chd.visible = false

ti najbrz skrije tudi svoje otroke, ali pač?

klemenSLO ::

REs je.
Life is not measured in minutes, but in MOMENTS...


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

[VB] polepšanje kode

Oddelek: Programiranje
7741 (647) korenje3
»

C# textbox polnjenje

Oddelek: Programiranje
71626 (1491) Mitja Bonča
»

vb.net: dynamic textbox

Oddelek: Programiranje
51174 (1064) saule
»

C# Program

Oddelek: Programiranje
393095 (2018) Spura
»

[VB express edition] problem

Oddelek: Programiranje
71366 (1269) frudi

Več podobnih tem