samedi 18 avril 2015

Programmatically check if TextBox has TextChanged EventHandler in C#

I'm developing a winform application in C# which in I add EventHandler for my TextBox programmatically.



txtBox.TextChanged += txtBox_TextChanged;


But I have this code in some other parts which I want to prevent addind another EventHandler if the EventHandler has already been added to TextBox. Somthing like this:



if("txtBox doesn't have txtBox_TextChanged")
txtBox.TextChanged += txtBox_TextChanged;


Is there anyway to do that other than setting a bool variable to true and checking it every time?


Aucun commentaire:

Enregistrer un commentaire