473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Repalce dot with comma

Hi!

How to replace dot with comma when user is typing somewhat in textBox?
I have wrote this part of code to detect typed dot, but how to
replace it with coma:

private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == (int)(char)'.')
{
e.Handled=true;

// TO DO

}
}

Thnx!
Feb 7 '08 #1
7 7834
On Feb 7, 9:43*am, Joza <josip.pejakovi...@SPAMetfos.hrwrote:
Hi!

How to replace dot with comma when user is typing somewhat in textBox?
I have wrote this part of code to detect typed dot, but how to
replace it with coma:

private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
* * * * if (e.KeyChar == (int)(char)'.')
* * * * {
* * * * e.Handled=true;

* * * * // TO DO

* * * * }

}

Thnx!
if (e.KeyChar == Convert.ToChar("."))
e.KeyChar = Convert.ToChar(",");
Feb 7 '08 #2
On 7 Feb, 14:43, Joza <josip.pejakovi...@SPAMetfos.hrwrote:
Hi!

How to replace dot with comma when user is typing somewhat in textBox?
I have wrote this part of code to detect typed dot, but how to
replace it with coma:

private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
* * * * if (e.KeyChar == (int)(char)'.')
* * * * {
* * * * e.Handled=true;

* * * * // TO DO

* * * * }

}

Thnx!
if(e.KeyChar == '.')
{
TextBox box = (TextBox)sender;
int pos = box.SelectionStart;
box.Text = box.Text.Insert(pos,",");
box.SelectionStart = pos + 1;
e.Handled = true;
}

You don't really need to use the box variable, it just makes it more
general purpose.
Feb 7 '08 #3
On 7 Feb, 14:58, za...@construction-imaging.com wrote:
On Feb 7, 9:43*am, Joza <josip.pejakovi...@SPAMetfos.hrwrote:


Hi!
How to replace dot with comma when user is typing somewhat in textBox?
I have wrote this part of code to detect typed dot, but how to
replace it with coma:
private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
* * * * if (e.KeyChar == (int)(char)'.')
* * * * {
* * * * e.Handled=true;
* * * * // TO DO
* * * * }
}
Thnx!

* * * * * * if (e.KeyChar == Convert.ToChar("."))
* * * * * * * * e.KeyChar = Convert.ToChar(",");- Hide quoted text -

- Show quoted text -
KeyChar is read only, well on 1.1 anyway, just getting 2008 installed
on this machine at the moment. If it's changed I'll post back.
Feb 7 '08 #4
DeveloperX wrote:
>
if(e.KeyChar == '.')
{
TextBox box = (TextBox)sender;
int pos = box.SelectionStart;
box.Text = box.Text.Insert(pos,",");
box.SelectionStart = pos + 1;
e.Handled = true;
}

You don't really need to use the box variable, it just makes it more
general purpose.
Thank you very much! That's it! :)
Feb 7 '08 #5
On Feb 7, 10:06*am, DeveloperX <ianathomeag...@googlemail.comwrote:
On 7 Feb, 14:58, za...@construction-imaging.com wrote:


On Feb 7, 9:43*am, Joza <josip.pejakovi...@SPAMetfos.hrwrote:
Hi!
How to replace dot with comma when user is typing somewhat in textBox?
I have wrote this part of code to detect typed dot, but how to
replace it with coma:
private void txtNum_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
* * * * if (e.KeyChar == (int)(char)'.')
* * * * {
* * * * e.Handled=true;
* * * * // TO DO
* * * * }
}
Thnx!
* * * * * * if (e.KeyChar == Convert.ToChar("."))
* * * * * * * * e.KeyChar = Convert.ToChar(",");- Hidequoted text -
- Show quoted text -

KeyChar is read only, well on 1.1 anyway, just getting 2008 installed
on this machine at the moment. If it's changed I'll post back.
It must be. I tested that code in VS2005 and it worked fine.
Feb 7 '08 #6
Nope...

if u paste code in (to the textbox) handeling it like that it wont
work I think... u know ctrl-v...

not while I tested it in 2005 anyways... but that was for 0-9 only
accepted... or was it VB6?

hmmm... dont remember.. well, tried the same solution and it worked
on kanual input but not on copy/paste

check what u got when u leave... and if wrong input warn user to
carefully RTFM, and exit program/bluescreen ;)

//CY
Feb 7 '08 #7
The specific case of dot/comma suggests international entry of numeric
values.- Dölj citerad text -
Hmm, 123,312.12 uses both... wich is wich.. is there a INTERnational
standard for the case? and if not why? yes u can put it in win doze
that it will read (or anyway write it that way) but is that
implemented... Im running circles around swedish chars... really nice
when going dipped in 7 bit somewhere... it sort of get like "Wdlcome"
instead of "Welcome"...

//CY
Feb 12 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Alberto Vera | last post by:
Hello: I have the next structure: How Can I make it using Python? How Can I update the value of 6?
4
by: Arne | last post by:
From: "Arne de Booij" <a_de_booij@hotmail.com> Subject: Comma delimited array into DB problems Date: 9. februar 2004 10:39 Hi, I have an asp page that takes input from a form on the previous...
5
by: Derek | last post by:
I came upon the idea of writting a logging class that uses a Python-ish syntax that's easy on the eyes (IMO): int x = 1; double y = 2.5; std::string z = "result"; debug = "Results:", x, y,...
11
by: Shawn Odekirk | last post by:
Some code I have inherited contains a macro like the following: #define setState(state, newstate) \ (state >= newstate) ? \ (fprintf(stderr, "Illegal...
21
by: siliconwafer | last post by:
Hi, In case of following expression: c = a && --b; if a is 0,b is not evaluated and c directly becomes 0. Does this mean that && operator is given a higher precedence over '--'operator? as...
9
by: Wayne | last post by:
I have the following string: "smith", "Joe", "West Palm Beach, Fl." I need to split this string based on the commas, but as you see the city state contains a comma. String.split will spilt the...
9
by: Igal | last post by:
hay. i have read some topics about this. but there's something i don't quite understand, if anyone can help. i have text, in it i want to highlight the words user used to find this result. i...
1
by: DavidB | last post by:
Is there a way in VBA to determine if the standard Search replace dialog is open (Access 2003)? I have code that I need to run OnCurrent EXCEPT when the Search Replace dialog is opne and the user...
15
by: Lighter | last post by:
In 5.3.3.4 of the standard, the standard provides that "The lvalue-to- rvalue(4.1), array-to-pointer(4.2),and function-to-pointer(4.3) standard conversions are not applied to the operand of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.