Solved

dbgrid behaviour

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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