Board index » delphi » DBGrid problem - difficult problem

DBGrid problem - difficult problem

Hi all

The problem I have is the following:
  I have a grid, in which I enter values under particular columns.
  I want to be able to get a value entered in a particular row under a
certain column.
  Once I know the value, I want to be able to say that if the value is, e.g
= 1 then
  a cell in the same row under another particular column is read only.
  I don't want to make the whole column read only, just a particular cell
in a particular row and under a particular column.

e.g.

The following fields exist:
      Category field
      Description field
      Amount

Under the column Category and in a new row, I enter 'Parking' .
I want to be able to tell Delphi to get that value and say that if it is
'Parking' then the Description field in that row must not be filled in, i.e
the description field must be read only.
I then want to be able to go to the next new row and enter a description if
a description is required.
All in all, I just would like to set a particular cell to readonly and not
affect the fields at all and not affect any other entries into new rows.

I hope I have explained it clear enough. If anyone can help, please do!!

Thanks.

 

Re:DBGrid problem - difficult problem


Have you tried something like this:

1. use the OnDataChange event for the datasource that supplies the
grid.
2. In that event handler, check the value of the controlling field.
        if <the value> = <whatever> then
                gridcolumn.readonly := true
        else    
                gridcolumn.readonly := false;

As I understand the grid component, the various cells are just a
visual thing. They can't be addressed individually. i.e., you can
address them only as the intersection of the current (selected) row
and a selected column.

HTH,
Dan

On 22 Apr 1998 10:14:11 GMT, "Wissa" <dono...@ar1.bp.com> wrote:

Quote
>Hi all

>The problem I have is the following:
>  I have a grid, in which I enter values under particular columns.
>  I want to be able to get a value entered in a particular row under a
>certain column.
>  Once I know the value, I want to be able to say that if the value is, e.g
>= 1 then
>  a cell in the same row under another particular column is read only.
>  I don't want to make the whole column read only, just a particular cell
>in a particular row and under a particular column.

>e.g.

>The following fields exist:
>      Category field
>      Description field
>      Amount

>Under the column Category and in a new row, I enter 'Parking' .
>I want to be able to tell Delphi to get that value and say that if it is
>'Parking' then the Description field in that row must not be filled in, i.e
>the description field must be read only.
>I then want to be able to go to the next new row and enter a description if
>a description is required.
>All in all, I just would like to set a particular cell to readonly and not
>affect the fields at all and not affect any other entries into new rows.

>I hope I have explained it clear enough. If anyone can help, please do!!

>Thanks.

--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control: Consulting, Software,
and the only comprehesive textbook on this subject.
visit us at www.cmdcsystems.com
[Remove the SPAM from my e-mail address]

Other Threads