Windows Develop Bookmark and Share   
 index > Windows Forms General > Panel contents
 

Panel contents

How can i determine the contents of a Panel control?

in my app i add some usercontrols inside the panel (one at a time, by clicking a button), but i need to check which usercontrol is currently on the panel, how can i do it?

I found something about checking if contains some control like: panel.contains(label1) but i can't do it when i add an UserControl, what's the correct syntax for that or what can i do?

Victor BA  Sunday, December 10, 2006 4:29 AM

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

' check to see if any of these controls are

' in panel1

MsgBox(InPanel("button1").ToString)

MsgBox(InPanel("button2").ToString)

MsgBox(InPanel("label1").ToString)

MsgBox(InPanel("label2").ToString)

End Sub

Private Function InPanel(ByVal Ctext As String) As Boolean

Dim n As Boolean = False

For Each j As Control In Me.Panel1.Controls

If j.Name.ToUpper = Ctext.ToUpper Then

n = True

End If

Next

Return n

End Function

End Class

Tall Dude  Sunday, December 10, 2006 5:43 AM

You can use google to search for other answers

Custom Search

More Threads

• rich text box fint string
• How to retrive the application path
• How can I do virtual mouse click?
• How can I draw background to image for TreeView's background.
• filling treeview control from xml file
• datagridview
• Why ToolStripItem inherits from Component instead of Control?
• How to set the DateTimePicker background color?
• Loading a TreeView Dynamicly with images from imagelist built on runtime
• Using EM_GETLINE