• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

How to relocate a Panel control to a TableLayoutPanel at runtime

Hi guys,
Is it possible to relocate a Panel control from Form.Panel.Controls to Form.Panel.TableLayoutPanel.Controls at runtime.

Thanks,
     Michael
0
gem56
Asked:
gem56
3 Solutions
 
Fernando SotoRetiredCommented:
Hi gem56;

Try it like this.

        Dim Pan() As Control

        Pan = Me.Panel.Controls.Find("RelocatePanel", False)
        Me.Panel.Controls.Remove(RelocatePanel)
        Me.TableLayoutPanel.Controls.Add(Pan(0))

Fernando
0
 
Wayne Taylor (webtubbs)Commented:
Hi Michael,

You can simply do this....

    TableLayoutPanel1.Controls.Add(Panel1)

Regards,

Wayne
0
 
gem56Author Commented:
Thanks guys,
webtubbs, your approach is shorter however would that not result in 'Panel1' appearing in both collections whereas FernandoSoto's would only appear in the new collection?

/Michael
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
A control can only have ONE container at any given time...so adding it to another Controls() collection AUTOMATICALLY removes it from its previous container.
0
 
gem56Author Commented:
Thanks for clarifying that point Bob.
/Michael
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You're welcome!

For future reference though:

    Idle_Mind --> Mike
    http://www.experts-exchange.com/M_1539809.html
   
    TheLearnedOne --> Bob
    http://www.experts-exchange.com/M_38421.html

;)
0
 
gem56Author Commented:
Ooopps!    
;-)
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now