Solved

dbgrid behaviour

Posted on 1997-11-11
2
139 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
Comment Utility
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
Comment Utility
Thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now