Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cells of a DBGrid

Status
Not open for further replies.

wrov

Programmer
Nov 1, 2002
43
PY
Hello everybody

Is it possible that a cell in a DBGrid be ReadOnly or not according to a condition ?

For example:
if the first column have a value of 10 then the second column will be ReadOnly.

I had tried the following code in the OnCellEnter event:

if Customer['CATEGORY'] = 10 then JustRead := True
else JustRead := False;
DBGrid1.Columns[1].ReadOnly := JustRead;

but it does not work if the user press the arrow down key.

Thanks in advance.

Walter.

 
Perhaps make a funtion containing the above code, and call it:

OnCellEnter

and

OnKeyPress (keypreview of form set to true)
(check which row is selected and disable the applicable rows accordingly)

If the code works OnCellEnter then you just have to make sure that it is being run on every possible way that the user can move about the stringgrid.

Hope that helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top