Advertisement
Guest User

Untitled

a guest
Jan 12th, 2024
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. var actions = new Dictionary<string, Action>();
  2. actions.Add("Lucene (Suche) Service neustarten", restartApp);
  3.  
  4. foreach (KeyValuePair<string, Action> entry in actions)
  5. {
  6.     // do something with entry.Value or entry.Key
  7.     Debug.WriteLine(entry.Key);
  8.     Debug.WriteLine(entry.Value);
  9.     Delegate dicFunc = new Action(() => entry.Value());
  10.  
  11.     Button action_button = new Button();
  12.     action_button.Text = entry.Key;
  13.     action_button.Click += new EventHandler(dicFunc);
  14.  
  15.     groupBox_article_actions.Controls.Add(action_button);
  16. }
  17.  
  18. void restartApp()
  19. {
  20.     MessageBox.Show("Restarted");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement