?
Solved

disable tdbgrid insert optins

Posted on 1998-06-23
4
Medium Priority
?
1,604 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

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!

Question has a verified solution.

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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 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