473,230 Members | 1,414 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,230 software developers and data experts.

Cursor position in NumericUpDown control

Hello C# gurus,
I have a question about finding cursor position in NumericUpDown control. On
my form I have a numericUpDown control with 2 decimal places. I want to
increment value in the numeric box by 1 if my cursor is in front of the
decimal point. If the cursor is after the decimal point, I want to increment
the value by 0.1. How do I accomplish this? Is there a way to find out the
cusror position in the control relative to decimal point?

Greatly appreciate any help you can provide,

Shridev
Nov 16 '05 #1
1 5016
Shridev,

I don't think that this is possible out of the box. The control doesn't
expose anything about the text that is in the box.

If you were to do it, you would have to take a look at the Cursor class
in the System.Windows.Forms namespace. It has a static property, Position
which gives you the position of the cursor in screen coordinates. Once you
have that, you can pass that point to the PointToClient method on the
numeric up/down control. This will give you the coordinates relative to the
control.

At that point, you are going to have to determine on which side of the
decimal point it is. I would try and use the TextRenderer class in the
System.Windows.Forms namespace (it's a new class in 2.0, and I wouldn't even
think of trying to calculate this stuff manually) and it can tell you the
width of text given a font and the text. You will have to parse apart your
string to get the widths, and then calculate the offsets to see if your
cursor is in the right place.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tantra Veda" <tv***@yahoo.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
Hello C# gurus,
I have a question about finding cursor position in NumericUpDown control.
On
my form I have a numericUpDown control with 2 decimal places. I want to
increment value in the numeric box by 1 if my cursor is in front of the
decimal point. If the cursor is after the decimal point, I want to
increment
the value by 0.1. How do I accomplish this? Is there a way to find out the
cusror position in the control relative to decimal point?

Greatly appreciate any help you can provide,

Shridev

Nov 16 '05 #2

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

Similar topics

21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
6
by: Chuck Bowling | last post by:
ok, I've scoured VS help, the Internet, books... I really hate the idea that I might have to end up creating an updown control from scratch just because I can't figure out how to turn off the %$@#...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
3
by: abc my vclass | last post by:
My win-form have many numericupdown controls to applied. But numericupdown control don't like textbox, text box control can automatic selected text when got focus. Is there any method can let me...
5
by: Len Weltman | last post by:
I am trying to pass a NumericUpDown object into a class method using Visual Studio 2005, but the control type is not found in Intellisense and the type declaration is flagged as an error. Here...
1
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
We have some dumb and lazy people here, so I need help. To fix the dumb part: We have placed MaskedTextBoxes on the forms so they will stop entering the information incorrectly. Now the lazy...
0
by: nagarjunt | last post by:
Hi, This is nag. I have a problem with infragistics7.1 UltraTextEditor control. I am using C# code in windows form. I have UltraTextEditor control(With multi line enabled) in my Windows...
4
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I...
2
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello experts, I posted a disturbing question in here:...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.