Search code examples
c#visual-studiogroupbox

Is it possible to hide textboxes and labels inside a groupbox?


I'm creating an Inventory system and I want to have different modules like Stocks Reports and Stocks Info in just a single form. Is it possible? Can groupbox allow this to happen? Thank you so much. Feel free to suggest and comment and please be nice. thanks again


Solution

  • As I've understood, you actually want to work with two different blocks in your single form. Then, you can simply create two GroupBoxes - groupBoxReports and groupBoxInfo.
    Then, you can drop all elements on your group boxes, so that group boxes contain these elements.
    Now, you can simply hide group boxes instead of manipulating with every element within it:

    public void showInfoButton_Click(object sender, EventArgs e) 
    {
        groupBoxReports.Visible = false;
        groupBoxInfo.Visible = true;
    }
    

    All elements within a group box are hidden as well.

    As mentionted in comments, you may want to work with TabControl instead of GroupBox, because it is exactly what it is designed for.