Yes, if you know in advance that's where it is then you can find it by
looping through Me.MyPanel.Controls.
In general if you want to iterate over all controls on a form , you
need a recursive solution like this:
'to call do this from somewhere in the form:
IterateControls(Me.Controls)
'this is the recursive proc
Sub IterateControls(cs As ControlCollection)
Dim cIter As Control
For Each cIter In cs
ProcessControl cIter
IterateControls cIter.Controls 'recurse down the hirerachy
Next
End Sub
'this is the processing routine that does whatever to a single control
Sub ProcessControl(c As Control)
'for example:
If TypeOf c Is Treeview Then
c.BackColor = Color.Red
End If
End Sub
Morten Snedker wrote:
On 17 Jun 2005 06:13:34 -0700, "Larry Lard" <la*******@hotmail.com>
wrote:
That may be it. The treeview actually is on a panel. Should I then
reference the treeview through the panel?
Your example code isn't actually setting the BackColor of any TreeView
- is your treeview on a panel maybe?
Remember that unlike the VB6 Controls collection, for a VB.NET Form,
Controls only includes the 'top-level' controls (ie not stuff *in a
container control* on the form).