Topic: Unable to disable a particular cell in a gridtable
I'm trying to make a table grid cell not editable once it has a value in it.
The below code works for checking if a cell is empty and allows in this case a date to be entered. It also allows the date to be changed again just by clicking on column 5, which what I don't want to happen. Note this is not using the datetimepicker as a visible component.
if Acol = col then //check if column 5 has been clicked
begin
//If column 5 has no tick in the checkbox
if frmMain.grdOrders.Cell[col,ARow].Empty = false then
begin
// update the grid with the date in column 4
frmMain.grdOrders.Cell[(col-1),ARow].asDateTime := dt; {dbdate function does not work here}
// update database
sqlexecute('UPDATE requests SET rec_date = "' + DBDateStr(dt,1)+'" WHERE id =' +
(frmMain.grdOrders.sqlValue));
end;
end;
However if I write this, the complete grid table no longer allows the date to be entered on the empty date column 4.
if (Acol = col) AND (frmMain.grdOrders.Cell[4,Arow].AsString = Null) then
begin
if frmMain.grdOrders.Cell[col,ARow].Empty = false then
begin
frmMain.grdOrders.Cell[(col-1),ARow].asDateTime := dt;
sqlexecute('UPDATE requests SET rec_date = "' + DBDateStr(dt,1)+'" WHERE id =' +
(frmMain.grdOrders.sqlValue));
end;
end;
end;
I've tried using frmMain.grdOrders.Cell[4,Arow].AsString = '', I've tried removing this part of the code from AND and using an If statement instead and I've tried changing frmMain.grdOrders.Cell[4,Arow].Empty = True.
None seem to do what I'm hoping for.