Visual Studio Developer Center > Visual Studio Forums > Visual Studio Class Designer > How to make a container control not contain a particular control?
Ask a questionAsk a question
 

QuestionHow to make a container control not contain a particular control?

  • Wednesday, October 14, 2009 2:32 PMK.Kong Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Scenario: Windows Forms application.

    I have never really figured out how a control gets "contained" by which container.  Most of the time it works, by dragging and making sure that a control is visually completely within the container control.

    How can I then have a control that is visually within a container but not to be Added to that container?  For example I have a button that I want to make it appear as belonging to different tabPages, but actually it is the same one button and I don't want it to belong to a particular TabPage.  The moment I drag it to be visually in a TabPage, Designer will generate the code like: this.tabPage1.Controls.Add(this.button1).  I don't want this.  I want the original this.Controls.Add(this.button1) before the TabPage control was added.

    Thanks.