Solved

Delphi Programming question

Posted on 1997-09-08
5
182 Views
Last Modified: 2010-04-04
Is it possible to make a DBEdit field to automatically exit to the next field (like pressing tab) as soon as it is totally filled? DBASE used to do that automatically.

Answer gotten and rated:

Proposed Answer from ptiemann...
yes, it is possible :-)
You have to write some eventhandler for the OnChange event. The following code exits to the next field when you have reached 12 characters.

You may derive your own component from TDBEdit that does this automatically so you don't have to code it for each control separately.

<code snipped>

Ok, (itamar) mentioned another solution to which I ofcourse also am interested. Other opinions are also welcome.. Fire away :)
0
Comment
Question by:avj
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
itamar earned 20 total points
ID: 1344407
It's similar to ptiemann's good answer, but it doesn't use Win API's. That is:

procedure TForm1.DBEdit1Change(Sender: TObject);
begin
      With Sender as TDBEdit do begin
            if Length(Text) = Field.DataSize Then
                  ActiveControl := TWinControl(Components[ComponentIndex + 1]);
      end;
end;

TIP: This kind of code is easier to share in all DBEdit's in your form.
0
 

Author Comment

by:avj
ID: 1344408
Wonderful, thanks. Only there is one complication I need to overcome, the field that I want to autoexit has an edit mask, which causes it to be filled with blanks up to the field max length immediately. So either I need to prevent the mask being filled with constants or to postpone the exit of the field until something is really typed in the last pos..
0
 
LVL 4

Expert Comment

by:itamar
ID: 1344409
Well, I think we have another question here, or at least an increased value ;)
Anyway, did you try to uncheck the 'Save literals characters' option ?

0
 

Author Comment

by:avj
ID: 1344410
Save literals is unfortunately also needed in this case..

0
 
LVL 4

Expert Comment

by:itamar
ID: 1344411
Couldn't it be something like that ?

>>>
procedure TForm1.DBEdit1Change(Sender: TObject);
begin
With Sender as TDBEdit do begin
if (Length(Text) = Field.DataSize) and <ADDITIONAL TEST> Then
   ActiveControl := TWinControl(Components[ComponentIndex + 1]);
end;
end;

Where in <ADDITIONAL TEST> you could check if the last position of the text is NOT the constant of mask.
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

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 79
How to fill array with TArray.Create? 14 79
FMX StringGrid1->Canvas->FillRect Problem 3 127
Help on project with Soap 10 48
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

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

16 Experts available now in Live!

Get 1:1 Help Now