Solved

dbgrid behaviour

Posted on 1997-11-11
2
144 Views
Last Modified: 2010-04-04
My problem

How (tabel, datasource, dbgrid) can I prevent the user editing the value in a particular cell, depending on the value in an other cell?
I tried it in the following way.

Tabel has two fields: CN and CNFLAG. If CNFLAG = TRUE changing the value of CN must be impossible. Therefore I tried to create an exception in the Onvalidate handler of CN.
if TABLECNFLAG.value then begin
                            exception.create('XXXXX');
                            abort;
                          end;
This brings up the message XXXXX but after that the user has to press the escapekey to redisplay the original value of CN. Is there an easy way to circumvent this problem?
0
Comment
Question by:ahjkuipers
[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 Comments
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 200 total points
ID: 1350034
Try this:

In the Datasource's Datachange event:

With Datasource1.Dataset DO
   Begin
     if FieldByName('CNFLAG').AsBoolean = TRUE then
        Begin
         FieldByName('CN').ReadOnly := True;
         Showmessage('Edits NOT allowed')
       end
else
    FieldByName('CN').ReadOnly := False;
   end;

Your datasource & fieldnames may be different.

Good luck with your project!
Pegasus
0
 

Author Comment

by:ahjkuipers
ID: 1350035
Thank you!
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

Suggested Solutions

Title # Comments Views Activity
HTML text in the body of an email (delphi code) 12 210
Delphi Yen format 3 61
firemonkey Android Listview Sort items 7 72
Firemonkey Queue list 1 28
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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