Guest User

Untitled

a guest
Aug 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public partial class Form1 : Form
  2. {
  3. public Form1()
  4. {
  5. InitializeComponent();
  6. panel1.Controls.Add(new Screens.UC1());
  7.  
  8. }
  9.  
  10. private void button1_Click(object sender, EventArgs e)
  11. {
  12. foreach (Control ctrl in panel1.Controls)
  13. {
  14. ctrl.Dispose();
  15. }
  16. panel1.Controls.Add(new Screens.UC1());
  17. }
  18.  
  19. private void button2_Click(object sender, EventArgs e)
  20. {
  21. foreach (Control ctrl in panel1.Controls)
  22. {
  23. ctrl.Dispose();
  24. }
  25. panel1.Controls.Add(new Screens.UC2());
  26. }
  27. }
  28.  
  29. public partial class UC1 : UserControl
  30. {
  31. public UC1()
  32. {
  33. InitializeComponent();
  34.  
  35. }
  36.  
  37. private void button1_Click(object sender, EventArgs e)
  38. {
  39. //Event to change text on UC2
  40. }
  41. }
  42.  
  43. public partial class UC2 : UserControl
  44. {
  45. public UC2()
  46. {
  47. InitializeComponent();
  48. }
  49.  
  50. public void WriteText(object sender, EventArgs e)
  51. {
  52. label2.Text = "Text Changed...";
  53. }
  54. }
Add Comment
Please, Sign In to add comment