Topic: Disable edit on a grid under condition

Hi all,

Is it possible to disable edit function in a result grid if a condition is met?

e.g: I have 2 grids: "top" and "bottom" and it is possible to edit the records in each grid

"bottom" grid results are based on "top" grid results

I would like to disable edit on bottom grid if result of top grid match a condition(Boolean column) so it would not be possible to edit the data.

Re: Disable edit on a grid under condition

Hello,


Do you want to disable editing by double click in grid?

example:

Form1.TableGrid1.dbPopupMenu.Items[0].Enabled:= False;
Dmitry.

3 (edited by tcoton 2015-10-16 14:18:58)

Re: Disable edit on a grid under condition

Hi,

yes I want to disable editing by double click on bottom grid if a column in top grid is contains a certain value.

I do not understand your script, could you explain please?

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=1409

Post's attachments

Attachment icon block_edit.png 41.62 kb, 311 downloads since 2015-10-16 

Re: Disable edit on a grid under condition

Example:

procedure Form1_GridTop_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
    if Form1.GridTop.Cells[9,ACol]='Yes' then
        Form1.GridBottom.dbPopupMenu.Items[0].Enabled:= False
    else Form1.GridBottom.dbPopupMenu.Items[0].Enabled:= True;
end;
Dmitry.

Re: Disable edit on a grid under condition

Unfortunately it does not work, column 9 is a Boolean value.

Re: Disable edit on a grid under condition

I can't help you if you say just " it does not work" )

Let me know more info.


Content of column is just text.

Dmitry.

Re: Disable edit on a grid under condition

When I say it does not work, I mean that even with your script, I still can edit the value of a row in bottom grid using double click which should not be the case smile

It makes no difference in short.

Re: Disable edit on a grid under condition

Please attach your project, I'll check it.

Dmitry.

Re: Disable edit on a grid under condition

Project sent by email, thanks in advance Dmitry.

Re: Disable edit on a grid under condition

Thank you Dmitry for fixing my project beyond expectation. You rock!

there was a little mistake in the script, this is how it has been fixed:


procedure Form1_GridTop_OnCellClick (Sender: string; ACol, ARow: Integer);
begin
    if Form1.GridTop.Cells[9,ARow]='Yes' then
        Form1.bottom_grid.dbPopupMenu.Items[0].Enabled:= False
    else Form1.bottom_grid.dbPopupMenu.Items[0].Enabled:= True;
end;