Forum > FPSpreadsheet
Problem with CellEdit.ReadOnly property
kjteng:
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:
Hi!
unit2.pas is missing in the zip file.
Winni
kjteng:
--- Quote from: winni on May 28, 2021, 02:10:19 pm ---Hi!
unit2.pas is missing in the zip file.
Winni
--- End quote ---
Sorry, my mistake. Reloaded test2.zip
winni:
Error:
project1.lpr could not be read
Winni
wp:
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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;
Navigation
[0] Message Index
[#] Next page