Solved

TDBGrid for Delphi 1

Posted on 1998-01-16
7
331 Views
Last Modified: 2010-04-04
When using a TDBGrid, with Delphi 1, how can you stop it creating a new record, when the user hits the tab key on the last record displayed.
0
Comment
Question by:nichs
[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
7 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1356901
I don't remember if D1 has the "abort" procedure.
But in general if you call this one in the BeforeInsert event for the TTable component then it cancels the creation of the new record.

Tell me if D1 has it or not, then I'll be able to check it more occurately.

Hope it helps,
Matvey
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1356902
Abort is to stop the printer from printing.
Instead you've to use the Cancel method.
Like Matvey says, in the beforeinsert event you put Table1.Cancel. (Opposite of Table1.Post)

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1356903
No no, I'm sure about this procedure, it just might be only in D3.
Maybe it's a new thing, but in D3 you can abort any procedure that has "Before" event by calling the "abort' proc.

IT'S NOT A METHOD
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Waldek
ID: 1356904
Maybe readonly set true
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1356905
I think that Abort is only defined in D3. Try to use Cancel.
0
 

Author Comment

by:nichs
ID: 1356906
Hi

I just wanted to say thanks for the comments to my question. I haven't had a chance to try them yet. Anyway Thanks!

..Nick
0
 
LVL 1

Accepted Solution

by:
millerw earned 100 total points
ID: 1356907
Nick--try this set of code-------

procedure TdmdStrategyYear.BeforeInsert(DataSet: TDataSet);
begin
//Used only on tabs 1 and 2 (zero based) of Setup.  Prevents user from adding
//an account to the files.
     tblAccounts.Cancel;
     tblSpreads.Cancel;
     SysUtils.Abort;
end;

That is the BeforeInsert event that I use in a program to accomplish the task.  Call the Table's Cancel event to tell the table to stop processing the insert.  Then use the Abort--defined in the SysUtils unit--to tell the TDbGrid to abort the keystroke.  That fixes it up nicely.  Can't remember WHY both calls are needed, but I remember it ran into a problem when I only called one or the other.  Try it if you want, but I'm pretty sure you have to include a call to both.

If you have problems, give me a ring.

BTW, this is D3 code so some of the procedures may not be included for D1, but the Abort should be in one way or another.  One way to fix it--kind of a round about way--is to intercept the Tab key in the KeyDown event of the TDBGrid.  In there just check to see what record you are on.  If you are on the last record and the last column (use SelectedField or SelectedIndex) then just throw out the key (Key:=0).  Word of warning about this-----MAKE SURE TO SET THE FORM THAT CONTAINS THE TDBGRID TO "KEYPREVIEW:=TRUE" SO THAT THE ASSIGNMENT OF KEY:=0 WILL WORK.

Cya,
Scott
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
Delphi Form ownership 4 152
Dev express lookupcombo 3 62
Browsing a TTreeView in Delphi 5 43
Remove all child-forms from a parent-panel 16 10
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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