Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing TextBox text

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I'm pretty new to C# and have encountered a problem. When the user types in a text box, I want that to change another control in my dialog. However, I want to be able to change the text box's text in my code using the TextBox.Text property without triggering the same event. I've managed to get around it so far, but this same kind of thing keeps coming up for many different controls and is very annoying, so I was wondering if there was any standard way of dealing with it.
 
I'm sorry, I can't really test this right now, but here's an idea just in case you need one in a hurry. I imagine that the KeyDown, KeyUp, and KeyPress events don't fire when you programatically insert text into a text box, but will fire when a user is entering text.

Basically, what I'm saying is that if you want to update controls on the form when the user enters text, you could use the KeyUp event.

Hope this helps.

-Aaron
 
I am VB, but the controls are the same. I have not used this myself. It seems that the Modified property is set only by the user changing the textbox or the code setting the property. I am not sure.
See TextBoxBase.Modified
Gets or sets a value that indicates that the text box control has been modified by the user since the control was created or its contents were last set.

Also see TextBoxBase.ModifiedChanged Event
Occurs when the value of the Modified property has changed.

Try setting the TextBoxBase.Modified = false when your code makes any change and then the TextChanged Event can see that the User did not make the change.







Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top