Jump to content


Photo

Error closing form when editing a cell

TNextGrid EditAccept

  • Please log in to reply
2 replies to this topic

#1 m610

m610
  • Members
  • 33 posts

Posted 04 January 2016 - 04:39 AM

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;



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 04 January 2016 - 07:58 PM

Hi Mike,

 

Can you please send me mini demo to I test it. I think that I have solved this issue long ago.

 

EndEditing should solve problem, but you don't need to call it all. Maybe some code inside one of Editing events is causing problems?


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 m610

m610
  • Members
  • 33 posts

Posted 10 March 2016 - 03:38 AM

My apologies for not checking back on this. Deadlines and all keep me from digging into things like this more.

 

EurekaLog helped me find a couple of memory leaks and when I took care of them the problem went away.

 

Thanks for your prompt response and offer to help.

 

Mike






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users