Solved

disable tdbgrid insert optins

Posted on 1998-06-23
4
1,539 Views
Last Modified: 2012-05-07
hi , anyonw knows how can i disable to options to add new record using tdbgrid control ?
using this dbgrid component and not with some Ttable properties ...
0
Comment
Question by:asi
  • 2
4 Comments
 
LVL 10

Expert Comment

by:Jacco
ID: 1355298
The only way of doing that is doing an Abort in OnInsert of the TTable, but that is what you don't want.

The other option is setting your DBGrid to ReadOnly or RowSelect...

Otherwise you have to derive a new TDBGrid.

Regards Jacco
0
 
LVL 2

Expert Comment

by:kjteng
ID: 1355299
It is not impossible but it will make you code messy:
Track the key code in keydown event, something like this:
  if key= VK_INSERT then key:=0;
  if key= VK_DOWN and atBottom then key:= 0
  ........
There is no such method/property as "atBottom" in dbgrid, you have to write some code to check whether you are at the end of file position.




0
 
LVL 10

Expert Comment

by:Jacco
ID: 1355300
Thanks for the comment :)
0
 
LVL 1

Accepted Solution

by:
michaue earned 20 total points
ID: 1355301
If I understand you correct you want to disable the user to add records to the TDBGrid but they must be able to edit them.  And you also don't want to disable the insert from the TTable component ...

Then the only thing I can think of is check the OnKeyDown event of the TDBGrid to check if the Insert button on your keyboard is pressed.

if Key = 45 then
  Cancel the insert that the user wants to do ...

45 is the value for the Insert key and KEY is the variable passed to the KeyDown event.

Hope it works

Elfrieda :)  PS :  Why don't you want to work with the TTable
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

21 Experts available now in Live!

Get 1:1 Help Now