In my app, I have three panels that make up the main screen. A header panel, a Navigation panel and a Main display panel.

When user clicks on the navigation button in nav panel, I use the following code to display the proper user control in main panel

Dim tempobject as new [usercontrol]
pnlMain.Controls.Clear()
pnlMain.Controls.Add(tempobject)

If I were to have a user control that contained sub menu items from a button in the nav panel,how would I call a new UC to the pnlMain if I am already in a UC in pnlMain?

Also, how would I create a generic function to accept a usercontrol (one that I want to display in pnlMain) as a parameter and display in pnlMain?

Something like this?

Public Sub GetUserControl(uc as System.Windows.Forms.Control)
Dim tempobject as new uc
pnlMain.Controls.Clear()
pnlMain.Controls.Add(tempobject)

That code isnt working, Getting error "value of type 'uc' cannot be converted to 'System.Windows.Forms.Control'