Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- panel1.Controls.Add(new Screens.UC1());
- }
- private void button1_Click(object sender, EventArgs e)
- {
- foreach (Control ctrl in panel1.Controls)
- {
- ctrl.Dispose();
- }
- panel1.Controls.Add(new Screens.UC1());
- }
- private void button2_Click(object sender, EventArgs e)
- {
- foreach (Control ctrl in panel1.Controls)
- {
- ctrl.Dispose();
- }
- panel1.Controls.Add(new Screens.UC2());
- }
- }
- public partial class UC1 : UserControl
- {
- public UC1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- //Event to change text on UC2
- }
- }
- public partial class UC2 : UserControl
- {
- public UC2()
- {
- InitializeComponent();
- }
- public void WriteText(object sender, EventArgs e)
- {
- label2.Text = "Text Changed...";
- }
- }
Add Comment
Please, Sign In to add comment