By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

C# Forms - Fire textbox event only from user interaction

P: 81
Hey All,
I can't see to find a nice solution to this. I have a textbox, and a button. When the textbox text is set by the user, I want the button to enable. When the text is set through code (ie. textbox.Text = "Hi"), I don't want it to fire the event. Is there an event that I can use that will listen only to user interaction and not programmatic changes?

Thanks
Aug 6 '08 #1
Share this Question
Share on Google+
3 Replies


Curtis Rutland
Expert 2.5K+
P: 3,256
Well, perhaps every time you modify the text in the code, you can set the button's enabled property to false.

That way, the TextChanged (or whatever, the event that fires when the text is changed) sets the button enabled, then the code resets it. But when the user changes the text, the button isn't reset to disabled.
Aug 6 '08 #2

P: 81
Well, perhaps every time you modify the text in the code, you can set the button's enabled property to false.

That way, the TextChanged (or whatever, the event that fires when the text is changed) sets the button enabled, then the code resets it. But when the user changes the text, the button isn't reset to disabled.
Right, it would just be nicer if we didn't have to worry and do that sort of dependency. Just curious if there was another approach that only listened to user input
Aug 6 '08 #3

P: 81
Right, it would just be nicer if we didn't have to worry and do that sort of dependency. Just curious if there was another approach that only listened to user input
We are also running into issues that there is no gurantee that:

tb.text ="hi";
button.Enabled = false;

No guarantees that button.Enabled gets run after the event, which means you run into cases where the button is not set.
Aug 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.