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 Format Bound to a Numeric Field

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
This seems simple and has probably been answered many times before but I can't seem to find a good answer. I have a textbox (Windows Form) bound to a numeric field in a table. Currently every time the value changes or I move to another record I have to reset the format with something like txtCustTotal.Text = FormatNumber(CustDataRow("CustTotal"),2,). Is there a way to set the format once and keep it's formatting when the value changes?

Auguy
Sylvania, Ohio
 
Have you tried using a masked text box?

You may want to create a custom controls that inherits from the masked text box, and specify the onTextChanged event to format the text the way you want it.

-The answer to your problem may not be the answer to your question.
 
Yes I have, maybe I will switch these fields and see if I like the results. Just thought I might have missed an obvious formatting method.

Auguy
Sylvania, Ohio
 
Select the textbox go to the Textbox Properties, expand the Databindings, select (Advanced) and the "Formatting and Advanced Bindings" dialog box will come up. With this dialog box you can set the number format for the field.

Perrin
 
Perrin, I don't see the Formatting dialog, but I do get the Advanced Data Binding dialog. I am using VB.net in VS 2003. Is this a feature in later versions, or do I need to do something else to see this dialog?

Auguy
Sylvania, Ohio
 
Auguy,

I was hoping you were using 2005, I don't think this was available in 2003. Another good reason to upgrade.
 
I've waited this long I think I will wait for VS 2008 due out in Feb. Don't know if there will be an upgrade path from 2003 to 2008 though. Haven't seen any pricing for 2008 yet.

Auguy
Sylvania, Ohio
 
You use the binding.parse and binding.format events to do this. Have a look at the Help for these events - it is explained there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top