Advertisement
Guest User

1

a guest
Nov 14th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Threading.Tasks;
  11.  
  12. namespace ex._1
  13. {
  14. public partial class Form1 : Form
  15. {
  16. public delegate void MyDelegate(string strName);
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22. private void button1_Click(object sender, EventArgs e)
  23. {
  24. this.Close();
  25. }
  26.  
  27. public void MyMessage(string str)
  28. {
  29. MessageBox.Show(str, "MyMessage", MessageBoxButtons.YesNo,MessageBoxIcon.Information);
  30.  
  31. }
  32.  
  33. private void button2_Click(object sender, EventArgs e)
  34. {
  35. string[] myStr = { "one", "two", "three" };
  36. MyDelegate delegate1 = new MyDelegate(MyMessage);
  37. foreach (string str1 in myStr)
  38. {
  39. delegate1(str1);
  40. }
  41. }
  42.  
  43. private void PictureMethod(string str2)
  44. {
  45. pictureBox1.Refresh();
  46. pictureBox1.Load(str2);
  47. }
  48.  
  49. private void button3_Click(object sender, EventArgs e)
  50. {
  51. MyDelegate delegate2 = new MyDelegate(PictureMethod);
  52.  
  53. foreach(string s in listBox1.Items)
  54. {
  55. delegate2(s);
  56. System.Threading.Thread.Sleep(2000);
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement