I have a method which adds a click-event to a Button at Runtime.
((Button)ControlDictionary[processDataProperty.Key]).Click += (s, e) => { Process.Start(processDataProperty.Value.ToString()); };
The process opens a page in a browser. The problem is that, executing this code several times, I get the undesired effect of a multiple opening tags.
I tried this but it does not work.
((Button)ControlDictionary[processDataProperty.Key]).Click -= (s, e) => { Process.Start(processDataProperty.Value.ToString()); };
((Button)ControlDictionary[processDataProperty.Key]).Click += (s, e) => { Process.Start(processDataProperty.Value.ToString()); };
I need a method that checks if I can add the method but I was not able to find a solution.
I tried also How to remove a lambda event handler with no good results.