Identify which textbox has fired a text changed event

后端 未结 3 1087
鱼传尺愫
鱼传尺愫 2021-01-19 05:19

I have a number of text boxes that are dynamically created via code.

I would like to be able to assign a generic event handler to all the textboxes for the text cha

3条回答
  •  -上瘾入骨i
    2021-01-19 05:37

    My advice is to look at the base class hierarchy at MSDN and just cast the control to it and extract the properties defined on it:

    var name = ((ContentControl) sender).Name;
    

    this is also a good practice for a more generic implementation because casting it to 'TextBox' means you can apply the handling logic to that type of control only.

提交回复
热议问题