Solved

disable tdbgrid insert optins

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

Independent Software Vendors: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

696 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