Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

dbgrid behaviour

Posted on 1997-11-11
2
Medium Priority
?
149 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 800 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

926 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