Solved

dbgrid behaviour

Posted on 1997-11-11
2
142 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
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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