How to visible in panels

S

Supra

I have 8 panels control on right side uing treeview control. this will
work in vb6 but can't figuring in vb.net. and i got error

Sub PanelVisible(ByVal szPanel As String)
Dim i As Integer, VisiblePanel As New Panel
For i = 0 To 7
If TypeOf VisiblePanel.Controls(i) Is Panel Then
===> Additional information: Specified argument was out of the range of
valid values.
If VisiblePanel.Controls(i).Name = szPanel Then
VisiblePanel.Controls(i).Visible = True

VisiblePanel.Controls(i).Location = New
Point(160, 8)
VisiblePanel.Controls(i).Size = New Size(304, 256)
Else
VisiblePanel.Controls(i).Visible = False
End If
End If
Next
End Sub

Private Sub trvPreference_AfterSelect(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles
trvPreference.AfterSelect
Dim i As String
i = e.Node.Text
Select Case i
Case "Connect"
Dim cConnect As String
cConnect = "Connect" 'Panel1.Name
PanelVisible(cConnect)

Case "User Info"
Dim cUser As String
cUser = "User Info" 'Panel2.Name
PanelVisible(cUser)

Case "Identd"
Dim cIdent As String
cIdent = "Ident" 'Panel3.Name
PanelVisible(cIdent)

Case "Firewall"
Dim cFireWall As String
cFireWall = "Firewalls" 'Panel4.Name
PanelVisible(cFireWall)

Case "DCC"
Dim cDCC As String
cDCC = "DCC" 'Panel5.Name
PanelVisible(cDCC)

Case "DNS"
Dim cDNS As String
cDNS = "DNS" 'Panel6.Name
PanelVisible(cDNS)

Case "Misc"
Dim cMisc As String
cMisc = Misc" 'Panel7.Name
PanelVisible(cMisc)

Case "Colours"
' Panel1.Visible = False
' Panel2.Visible = False
' Panel3.Visible = False
' Panel4.Visible = False
' Panel5.Visible = False
' Panel6.Visible = False
' Panel7.Visible = False
'With Panel8
' .Visible = True
'.Location = New Point(160, 8)
'.Size = New Size(304, 268)
'End With

Dim c As String
c = "Colours" 'Panel8.Name
PanelVisible(c)

End Select
End Sub

ne ideas u can help me?
regards
 
M

Mick Doherty

Dim VisiblePanel As New Panel
How many panels did you declare here? Looks like 1 to me.
For i = 0 To 7
If TypeOf VisiblePanel.Controls(i) Is Panel Then
There's only one VisiblePanel Object so you will get an out of range error.


I think you meant to enumerate the Panels on the form.

\\\
Sub PanelVisible(ByVal PanelObj As Panel)
For Each obj As Control In Me.Controls
If TypeOf obj Is Panel Then
If obj Is PanelObj Then
obj.Visible = True
obj.Location = New Point(160,8)
obj.Size = New Size(304,256)
Else
obj.Visible = False
End If
End If
Next
End Sub
///
 
S

Supra

hi mike,
what i'm attempting to do is when user click
treeview_afterselect.........for example clicking "Connect" will turn
this panel visible to true and rest of panels will be invisible to
false and if user click "Identd" will turn this panel visible to true
and rest of panels will be invisible to false and so forth...

ne ideas u can help me.
regards
how do u call PanelVisible in Private Sub treeview_AfterSelect?
 
C

Cor Ligthert

Supra,

Typed in this message not tested so watch typos and other errors.
\\\
Dim myPanel As Panel() = New Panel() {Panel1, Panel2, etc right panel names}
For i as integer = 0 to 7
if i = selectedindex then
myPanel(i).visible = true
else
myPanel(i).visible = false
end if
Next
///

I am curious is there a reason why you ask this question in this newsgroup
instead of the newsgroup
microsoft.public.dotnet.languages.vb ?

I hope that the solution above helps?

Cor
 
S

Supra

hi mike,
how do u call procedure events?
hi mike,
what i'm attempting to do is when user click
treeview_afterselect.........for example clicking "Connect" will
turn this panel visible to true and rest of panels will be invisible
to false and if user click "Identd" will turn this panel visible to
true and rest of panels will be invisible to false and so forth...

ne ideas u can help me.
regards
 
S

Supra

thank mike

i got it working
i can called like this:
PanelsVisible(Panel8)
WOOOOOOOOOOOOOOOOOOOOWwwwwwwwwwwwwww!
regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top