Advertisement
Guest User

Untitled

a guest
Feb 15th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3.  
  4. namespace WindowsFormsApplication2
  5. {
  6. public partial class Form1 : Form
  7. {
  8. private UC1 uc1 = new UC1();
  9. private UC2 uc2 = new UC2();
  10.  
  11. public Form1()
  12. {
  13. InitializeComponent();
  14. }
  15.  
  16. private void buttonUC1_Click(Object sender, EventArgs e)
  17. {
  18. displayPanel.Controls.Clear();
  19. displayPanel.Controls.Add(uc1);
  20. }
  21.  
  22. private void buttonUC2_Click(Object sender, EventArgs e)
  23. {
  24. displayPanel.Controls.Clear();
  25. displayPanel.Controls.Add(uc2);
  26. }
  27.  
  28. /// <summary>
  29. /// Clean up any resources being used.
  30. /// </summary>
  31. /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
  32. protected override void Dispose(bool disposing)
  33. {
  34. if (disposing && (components != null))
  35. {
  36. components.Dispose();
  37. uc1.Dispose();
  38. uc2.Dispose();
  39. }
  40. base.Dispose(disposing);
  41. }
  42. }
  43. }
  44.  
  45. using System;
  46. using System.Windows.Forms;
  47.  
  48. namespace WindowsFormsApplication2
  49. {
  50. public partial class UC1 : UserControl
  51. {
  52. private Int32 count;
  53.  
  54. public UC1()
  55. {
  56. InitializeComponent();
  57. }
  58.  
  59. private void button_Click(Object sender, EventArgs e)
  60. {
  61. count++;
  62. textBoxCount.Text = count.ToString();
  63. }
  64. }
  65. }
  66.  
  67. using System;
  68. using System.Threading;
  69. using System.Threading.Tasks;
  70. using System.Windows.Forms;
  71.  
  72. namespace WindowsFormsApplication2
  73. {
  74. public partial class UC2 : UserControl
  75. {
  76. public UC2()
  77. {
  78. InitializeComponent();
  79. }
  80.  
  81. private async void button1_Click(Object sender, EventArgs e)
  82. {
  83. Application.UseWaitCursor = true;
  84. await Task.Run(() => Thread.Sleep(5000));
  85. Application.UseWaitCursor = false;
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement