Why Text_Changed event of TextBox does not fire when we change its text programmatically?

Go To StackoverFlow.com


I have designed a softkeypad and changing textbox text programmatically such as

myKeypad.getControl.Text += "Char";

but textbox textchanged event does not fire. How can I solve this problem? Is it possible that we can create custom textChanged and KeyPressed Events which can fire by changing text or key press by softkeypad programmatically?

2012-04-04 05:18


It should be triggered.

From MSDN Control.TextChanged Event:

This event is raised if the Text property is changed by either a programmatic modification or user interaction.

Where are you adding the Event Handler?

2012-04-04 05:22
by Alexandre
! Both TextBox and Keypad are contained by a form and TextBoxTextChanged Event also included in this form. Custom Control 'Keypad' can access the textbox and change its text in its own class. (Sorry for bad English - NASSER 2012-04-04 05:26
The event is most likely consumed by your Custom Control if I had to guess. You should set up some break points inside your TextChanged event of your controls. I'm sure you'll figure out what is wrong rather quickly - Alexandre 2012-04-04 05:31