Recent

Author Topic: Clear a form?  (Read 7511 times)

captian jaster

  • Guest
Clear a form?
« on: October 26, 2010, 06:08:32 pm »
How can I clear the components of a form and replace them with new ones?
No to show the modal in a new window. Show the components in the same form...

eny

  • Hero Member
  • *****
  • Posts: 1628
Re: Clear a form?
« Reply #1 on: October 26, 2010, 06:14:11 pm »
Right click, Delete Selection   >:D
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...

Bart

  • Hero Member
  • *****
  • Posts: 4936
    • Bart en Mariska's Webstek
Re: Clear a form?
« Reply #2 on: October 26, 2010, 07:31:32 pm »
At runtime you mean?

Bart

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8748
  • Debugger - SynEdit - and more
    • wiki
Re: Clear a form?
« Reply #3 on: October 26, 2010, 07:40:57 pm »
Either use TPage without headers,
or design individual frames, and then show (Visible) one frame at a time.

captian jaster

  • Guest
Re: Clear a form?
« Reply #4 on: October 27, 2010, 12:01:08 am »
At runtime you mean?

Bart
Yes this.. Sorry about that..

Either use TPage without headers,
or design individual frames, and then show (Visible) one frame at a time.
This sounds about right...
But I need to be able to dynamically add TEdits to the form. Sort of like an Array of them. Though I can just use a stringrid :\ ... 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8748
  • Debugger - SynEdit - and more
    • wiki
Re: Clear a form?
« Reply #5 on: October 27, 2010, 12:40:01 am »
Either use TPage without headers,
or design individual frames, and then show (Visible) one frame at a time.
This sounds about right...
But I need to be able to dynamically add TEdits to the form. Sort of like an Array of them. Though I can just use a stringrid :\ ... 

Ok, what stops you?

The TFrame can be used to swap between different "displays"

Then let's say "Frame3" is visible, and you need edits on it

Code: [Select]
with TEdit.Create(Frame3)
  Parent := Frame3OrSomePanelInFrame3;
  Left := 0;
  Top := 50;
  // or use align, or anchors....
end;

If you need to remove them , you can keep them in an array:
  TEditArray = Array of TEdit;
but be aware, if you destroy (not hide, but really destroy) the frame, then the edits are destroyed too, and the refs in the array are pointing to random mem

or use TFrame.ComponentCount / TFrame.Components  to find the edits, by going over all the components displayed on that frame.
"Components goes by Owner, not by parent. So even if the edits are on a panel, they are owned by the Frame.
Use ControlCount / Controls for parent relationship




 

TinyPortal © 2005-2018