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!

TextBox behavior

Status
Not open for further replies.

andegre

MIS
Oct 20, 2005
275
US
I have a real brain teaser for y'all. I have a textbox on a form that is acting weird. When I enter data into the control, it works great. But when I delete all the data that is in their, it works fine, but as soon as I move the focus to a different control on the form, it puts that value that I deleted back into the control.

There are no events that fire that should be causing this behavior (that I can tell). Here is a snippet of the InitializeComponent method to show that nothing is going on:

this.txtCustomerNumber.Location = new System.Drawing.Point(168, 116);
this.txtCustomerNumber.Name = "txtCustomerNumber";
this.txtCustomerNumber.Size = new System.Drawing.Size(128, 20);
this.txtCustomerNumber.TabIndex = 15;
this.txtCustomerNumber.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckEnterKeyPressed);

The "this.CheckEnterKeyPressed" is just like it sounds, it only checks if enter was pressed, then does some other processing.

If anyone has any suggestions, or hints how to find this "error", I would greatly appreciate it.

Thanks,
andegre
 
What events do you have coded for this textbox?

Is it referenced from any other events in your application that might be changing it back?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Doing a search by "txtCustomerNumber", the only thing I find is 1 reference in a "BindUtil" method. If this is bound to something, would that be the possible culprit?
 
It could well be. What code is related to the textbox in that method?

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Found out a couple more things about this form/control. The form has the "AutoValidate" property set to "EnablePreventFocusChange". Also, the "CausesValidation" property is set to "true" also. I think I just need to find where that validation is done and I can move forward.

Back to my original reply about the data being bound. I tried setting the value in the dataset this it is bound to in the "Leave" event of the control, and it threw an error saying "Input string was not in a correct format.Couldn't store <> in CustomerNumber column. Expected type is Int32." That tells me that it's in the validation code someplace, now I just need to find out where that is...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top