A
A
Artem2016-07-09 17:44:30
Programming
Artem, 2016-07-09 17:44:30

How to open a window with C# buttons on button click?

Good evening! The application starts with the main page. By clicking on any of the proposed buttons, we are thrown into a window with the same header and bottom of the application, but in the middle of the window (as shown in the example), 0 we have links to some pdf files or even others buttons. When you click from "button 1" to the main one, you need to close the window that opened when you click on "button1". I can only think of creating a new form with the creation of the same header and adding buttons there. I tried to inherit from the parent form, but this form could not be changed. How can this be implemented?
2109e1c58d2b4a7ea283d28f374135e1.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Johnny Gat, 2016-07-09
@Deni74

Screenshots
14aa19edad0b4df5852e1e4d517f98e9.jpg
270de4ad454d4924967a9fe6f24f7409.jpg

Only one form is needed.
The element that will contain the variable part is "TabControl" (tabControl1) with five tabs, tab #0 for the main "page", tab #1 for "button 1", etc.
How to remove the "tails" on which in this example it says "tabPage1", ..., "tabPage5" is described here .
Click handler for "button 1" (for other buttons - by analogy):
private void button1_Click(object sender, EventArgs e)
{
    tabControl1.SelectTab(1);
}

On the second screen, the text "BUTTON 1" is displayed in the element "Label" (label5).
Click handler for this element:
private void label5_Click(object sender, EventArgs e)
{
    tabControl1.SelectTab(0);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question