Problem with CellEdit.ReadOnly property lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- kjteng · 2021-05-28 11:22 I set the CellEdit1.readonly property to True to prevent user from changing the cell content. However, the moment when the user exit the CellEdit component (eg. click on other component), the CellEdit.ReadOnly property automatically changed to False. attached sample project. Please help. ---------------------------------------------------------------------- winni · 2021-05-28 12:10 Hi! unit2.pas is missing in the zip file. Winni ---------------------------------------------------------------------- kjteng · 2021-05-28 12:19 Quote from: winni on May 28, 2021, 02:10:19 pmHi! unit2.pas is missing in the zip file. Winni Sorry, my mistake. Reloaded test2.zip ---------------------------------------------------------------------- winni · 2021-05-28 12:45 Error: project1.lpr could not be read Winni ---------------------------------------------------------------------- wp · 2021-05-28 12:47 You must also consider the protection state of the worksheet, there is a method worksheet.Protect(boolvar) with which you can disable editing of the entire worksheet (https://wiki.lazarus.freepascal.org/FPSpreadsheet#Protection). Unfortunately the controls do not cooperate with the worksheet here very well, so you must also protect the visual controls. This code works for me in your project: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.CheckBox1Change(Sender: TObject);begin  if CheckBox1.Checked then    begin      gr1.Options := gr1.Options  - [goEditing];      label1.Caption := '<- Readonly';    end  else    begin      gr1.Options := gr1.Options  + [goEditing];      label1.Caption := '<- Editable';    end;  sCellEdit1.ReadOnly := CheckBox1.Checked;  wbs1.Worksheet.Protect(Checkbox1.Checked);end; ---------------------------------------------------------------------- kjteng · 2021-05-28 13:13 Quote from: wp on May 28, 2021, 02:47:21 pmYou must also consider the protection state of the worksheet, there is a method worksheet.Protect(boolvar) with which you can disable editing of the entire worksheet (https://wiki.lazarus.freepascal.org/FPSpreadsheet#Protection). Unfortunately the controls do not cooperate with the worksheet here very well, so you must also protect the visual controls. This code works for me in your project: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.CheckBox1Change(Sender: TObject);begin  if CheckBox1.Checked then    begin      gr1.Options := gr1.Options  - [goEditing];      label1.Caption := '<- Readonly';    end  else    begin      gr1.Options := gr1.Options  + [goEditing];      label1.Caption := '<- Editable';    end;  sCellEdit1.ReadOnly := CheckBox1.Checked;  wbs1.Worksheet.Protect(Checkbox1.Checked);end; Thank to master for your suggestion.  It means there is no way to change this behavior (automatically change of Readonly property)  in the component?  BTW, currently I am using the following code to workaround this problem but not sure whether there will be 'side effect' : procedure TForm2.sCellEdit1Enter(Sender: TObject); begin   sCellEdit1.ReadOnly := Checkbox1.Checked; end; ---------------------------------------------------------------------- wp · 2021-05-28 13:56 The problem is that when I take the CellEdit's ReadOnly seriously there may be a conflict with the grid which maybe can be allowed for editing. And what if only one particular cell would allowed for editing which for all the others it would be disallowed? This is a very confusing situation (ok - the current situation is even more confusing...). The readonly properties are determined by the state the worksheet protection as described in the wiki. Look at attached demo file. Here, the entire worksheet is blocked from editing except for the yellow one, you can verify this with spready or the demo_ctrls sample project. So, the basic idea is to leave the ReadOnly property alone and to define protection using the properties of the worksheet from which the visual controls get their data and their behaviour.