Solved

Delphi Programming question

Posted on 1997-09-08
5
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 79
Multiple image collision 13 111
FMX and jaudiotracker playing memory stream 29 108
Formating a integer number to float 2 10
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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