Hi,
I have a grid in component which is in a form and I am having trouble when I close the form, but only if the grid cell was being edited and only if I close the form by clicking the X in the header. Clicking my "Close" button does not cause this error.
The access violation error occurs in:
function TNxCustomGridControl.ApplyEditing: Boolean;
var
Accept: Boolean;
Value: WideString;
begin
Result := False;
if (gtEdit in GridState) then
begin
Accept := True;
{ 9/7/07: Spin edit need to adjust bounds on editing done }
FInplaceEdit.ApplyEditing;
Value := FInplaceEdit.Text;
Columns[FEditingCell.X].ApplyEditing(Value);
.
.
The editor highlights the last line, so the Value:=... line was probably the problem.
.
If in my component's Desctructor routine I place Grid.EndEditting before Grid.Free I get a different access violation, this time in:
function TNxColumns.GetCount: Integer;
begin
Result := FItemsList.Count;
end;
Here's my destructor routine.
destructor TGST_Panel.Destroy;
begin
CyclesLbl.Free;
CyclesValueLbl.Free;
CyclesSE.Free;
CycleTimeLbl.Free;
Cycle_TimeLbl.Free;
TotalTimeLbl.Free;
Total_TimeLbl.Free;
Option1Pnl.Free;
StartTempLbl.Free;
StartTempValueLbl.Free;
StartTempEdit.Free;
Option2Pnl.Free;
Grid.EndEditing;
Grid.Free;
inherited Destroy;
end;
I tried moving the grid line to the top, figuring maybe a component that had just been freed was being accessed, but that did not help.
Is there a way to cancel the edit rather than end it? Or is there something else I should try?
Thanks,
Mike
Edit -- I moved the EndEditting line to the OnCloseQuery routine in the form and I still get the error in Result := FItemsList.Count;