Solved

tabbing from one mask edit to another automatically

Posted on 1998-07-01
12
147 Views
Last Modified: 2010-04-04
the users of my application have to enter 2 numbers in two separate mask edit fields. These are numeric values. I would like the focus to jump to the second mask edit when the first one is filled with digits (sort of like the Windows 95 authentication code.
0
Comment
Question by:sharons
12 Comments
 
LVL 1

Expert Comment

by:michaue
ID: 1356879
Set the MaxLength property of MaskEdit1 (at design time) to the maximum number of digits you want entered into the field.

And on the OnKeyUp event of MaskEdit1 put the following code

if Length(MaskEdit1.Text) = MaskEdit1.MaxLength then
  MaskEdit2.SetFocus;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356880
michaue, Did you check it?
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356881
Yes, Why?  :)
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356882
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356883
michaue, Did you check it?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356884
Because if you put some mask then it's not working. Put the following mask:
MaskEdit1.EditMask:='!\(999\)000-0000);1;_'
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Expert Comment

by:michaue
ID: 1356885
Sorry, I didn't check it with the mask ....
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356886
Here's the sollution with mask edit characters included:

You have to declare a variable to hold the character count, and initialize it with the value of mask characters for which the user won't enter anything (like spaces etc)

You don't have to set the MaxLenght property when you add and EditMask to MaskEdit1, because it will put the value in as soos as you change the EditMask property.

Then in the KeyPress event of MaskEdit1 put the following code ...

Count := Count + 1;
if Count = MaskEdit1.MaxLenght then
  MaskEdit2.SetFocus;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356887
But then if you are pressing the left arrow key, meaning going back, then the Count will not have the right value of the cursor position, so in this case it will not work properly.
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356888
Any suggestions ?
0
 
LVL 3

Accepted Solution

by:
vladika earned 50 total points
ID: 1356889
Try it

procedure TForm1.MaskEdit1KeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if MaskEdit1.SelStart = MaskEdit1.MaxLength then MaskEdit2.SetFocus;
end;

0
 

Author Comment

by:sharons
ID: 1356890
It works great.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now