Designing Windows.Form with multiple panels -> How to hide one panel (like a PS layer)

前端 未结 3 1862
夕颜
夕颜 2021-02-10 17:11

How can I hide one panel in Visual Studio 2008 Form Designer like a layer in PS? Otherwise, can someone recommend another better method to design multiple \"screens\" that must

3条回答
  •  有刺的猬
    2021-02-10 17:57

    Another less elegant, but quick hack, approach is to simply not add the panel to the parent form until runtime. In doing that, the designer has no idea where the panel belongs prior to compilation, and it won't be displayed.

    For example, find the block of code where you add controls to the parent form:

                    //this->Controls->Add(this->panel_X);
            this->Controls->Add(this->tabControl);
            this->Controls->Add(this->menuStrip_topMenu);
    

    Comment or remove the statement, then find the handle to the event that occurs when the form is loaded:

            this->Load += gcnew System::EventHandler(this, &MainForm::MainForm_Load);
    

    Then in the definition of the event handler, add the control to the form:

    System::Void MainForm_Load(System::Object^  sender, System::EventArgs^  e) {
    ...
    ...
    this->Controls->Add(this->panel_X);
    }
    

    I haven't experienced any unwanted side effects by doing this, but if anyone has a good reason to not I'd be interested in hearing it.

提交回复
热议问题