hi friends....
I want to create a textbox like Windows XP Calculator's textbox by this condition:
1 -the digits separate by comma (digit Grouping) like Windows XP Calculator's textbox
2 -the decimal part of number don't get digit grouping option .
example of this textbox format :
1,234,567.6576
0.2123423423423423
-1,2332,33.232023
7 Replies - 846 Views - Last Post: 12 August 2012 - 06:42 AM
#1
How Can I create a TextBox with Digit Grouping option
Posted 10 August 2012 - 03:12 AM
Replies To: How Can I create a TextBox with Digit Grouping option
#2
Re: How Can I create a TextBox with Digit Grouping option
Posted 10 August 2012 - 03:56 AM
You will need to format your string to currency format. Look this example:
http://www.java2s.co...matCurrency.htm
http://www.java2s.co...matCurrency.htm
#3
Re: How Can I create a TextBox with Digit Grouping option
Posted 11 August 2012 - 03:17 AM
thanks...
but i don't want to use the currency format.i know that it is possible to use FormatNumber to do this.how? i don't know
if you know how please tell me.
but i don't want to use the currency format.i know that it is possible to use FormatNumber to do this.how? i don't know
if you know how please tell me.
#4
Re: How Can I create a TextBox with Digit Grouping option
Posted 11 August 2012 - 03:50 AM
Ya sure you can, the .net has number format which you can use to do what you want to do:
Look at the following msdn library on how to use group separator for number format.
http://msdn.microsof...v=vs.71%29.aspx
http://msdn.microsof...y/0c899ak8.aspx
Look at the following msdn library on how to use group separator for number format.
http://msdn.microsof...v=vs.71%29.aspx
http://msdn.microsof...y/0c899ak8.aspx
#5
Re: How Can I create a TextBox with Digit Grouping option
Posted 11 August 2012 - 06:05 AM
smohd, on 11 August 2012 - 03:50 AM, said:
Ya sure you can, the .net has number format which you can use to do what you want to do:
Look at the following msdn library on how to use group separator for number format.
http://msdn.microsof...v=vs.71%29.aspx
http://msdn.microsof...y/0c899ak8.aspx
Look at the following msdn library on how to use group separator for number format.
http://msdn.microsof...v=vs.71%29.aspx
http://msdn.microsof...y/0c899ak8.aspx
thanks dear friend
this two way exactly are what i want.but a problem remains.how can do this in each time that i press the key.see below :
Perss Key ::::> 1
textbox.text=1
Perss Key ::::> 12
textbox.text=12
Perss Key ::::> 123
textbox.text=123
Perss Key ::::> 1234
textbox.text=1,234
Perss Key ::::> 1234.5
textbox.text=1,234.5
i hope you understand what i want.
in your guidance the number complete send to func and it's return value is my purpose .but i want that it work in each time i press the key and input new added value
#6
Re: How Can I create a TextBox with Digit Grouping option
Posted 11 August 2012 - 06:23 AM
Then you will need to put in either TextChanged or KeyUp or other related events of the textbox you are referring to.
#7
Re: How Can I create a TextBox with Digit Grouping option
Posted 12 August 2012 - 05:47 AM
smohd, on 11 August 2012 - 06:23 AM, said:
Then you will need to put in either TextChanged or KeyUp or other related events of the textbox you are referring to.
hi again...
i put this code in Text_Change event :
Private Sub T_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T.TextChanged
T.Text = FormatNumber(T.Text, , , , TriState.True)
T.Selectionstart = T.TextLength
End Sub
but it doesn't work.only first digit that i press has shown with two decimal digit.for example first key =1 then textbox1.text=1.00 and it doesn't change.
please tell me why it happens.and what should i do?
EDIT*: Please use code tags, they will format your code better than using color
This post has been edited by smohd: 12 August 2012 - 06:44 AM
Reason for edit:: code tags added
#8
Re: How Can I create a TextBox with Digit Grouping option
Posted 12 August 2012 - 06:42 AM
Try to put in Leave or LostFocus, but you will need to to click to another control for the code to take effect.
Or you can put a label where a formatted string is displayed.
Or you can put a label where a formatted string is displayed.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|