Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

disable tdbgrid insert optins

Posted on 1998-06-23
4
Medium Priority
?
1,630 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
[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
  • 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 40 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 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