Solved

disable tdbgrid insert optins

Posted on 1998-06-23
4
1,562 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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