Show different panels in the same form with c #

0

Hello, I'm trying to create different pages in the same form, let's say I'll have several labels like the following:

Then when I give Main the panel will be white. But when you give it to label1, the panel will be dark like this:

The code will simply be a form like this:

namespace Espacio
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        void Form1Load(object sender, EventArgs e)
        {

        }
    }
}

In short, I will have two panels. When I give the label Main - > It will show me my first panel. When I give it to label2 - > will show me my second panel.

With tab I am left as follows:

and what I want is that tab1 tab2 is on the left so I use panels and labels. What you do not understand is how to superimpose one panel on another according to the label that you click to change it and show me another.

    
asked by Sergio Ramos 29.05.2017 в 20:38
source

1 answer

0

If what you have is a panel on another one, it would be enough to hide or show the second panel according to one label or the other. Something like this:

private void BtnVerPanel1_Click(object sender, EventArgs e)
    {
        Panel2.Hide();
    }
    private void btnVerPanel2_Click(object sender, EventArgs e)
    {
        Panel.Show();
    }

Another option is that you want to do something like this:

That supposing you use WPF would be something like this:

<TabControl HorizontalAlignment="Left" Height="299" Margin="10,10,0,0" VerticalAlignment="Top" Width="497" TabStripPlacement="Left">
        <TabItem Header="TabItem">
            <Grid Background="#FFE5E5E5"/>
        </TabItem>
        <TabItem Header="TabItem">
            <Grid Background="#FFE5E5E5"/>
        </TabItem>
    </TabControl>

The important part would be TabStripPlacement="Left"

If what you use in WindowsForm, as it seems, then the solution that @gbianchi tells you in your comment seems to work. Or if you can not put something like this by changing the property this.tabControl1.Alignment = TabAlignment.Left; Visiting something like this

Greetings and I hope one of these things works for you.

    
answered by 30.05.2017 / 07:53
source