Highlighted
Alex_Castro Respected Contributor.
Respected Contributor.
82 views

Setting Cursor Position in Masked Field WinForm

Jump to solution

I have a masked amount field in Windows Form as follows:

“9999999.99” (_______.__) which would look like:

1234567.89

 

When I launch the form, the cursor starts on the first position on the left which would be the number 1. I would like the cursor’s position to start on the first position on the right where the 9 is. It would be easier for the user to start typing from right to left as the amount field is more likely to be in 100’s position (e.g. $567.89). If the cursor’s position starts on the left, the user is forced to use the arrow key to get to the 100’s position (where the number 5 begins). I have tried the following:

 

set maskedTextBox1::SelectionStart to 8.

 

But this does not work as the “SelectionStart” keeps defaulting to 0. Manipulating the cursor position in C# is as follows:

Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);

 

I tried a similar command as follows:

set maskedTextBox1::Cursor to new System.Drawing.Point(50, 50).

This command however does not compile.

0 Likes
1 Solution

Accepted Solutions
Austin1 Honored Contributor.
Honored Contributor.

Re: Setting Cursor Position in Masked Field WinForm

Jump to solution
0 Likes
2 Replies
Austin1 Honored Contributor.
Honored Contributor.

Re: Setting Cursor Position in Masked Field WinForm

Jump to solution
0 Likes
Alex_Castro Respected Contributor.
Respected Contributor.

Re: Setting Cursor Position in Masked Field WinForm

Jump to solution
I think this will work, thank you!
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.