0

I want to control the order of paint each of the control at the form.

I know that I can control it at the design move and it actually change creation order of controls at the form.

But is there way to change that at runtime?

Sir Rufo
  • 18,395
  • 2
  • 39
  • 73
  • Guess one could make a custom TControl editor for that, probably could base it on this one: https://en.delphipraxis.net/topic/2787-addon-to-hide-single-visual-controls-in-form-designer/?tab=comments#comment-22178 - I'd show a list of children names in such editor allowing to reorder them. Would be nice if the IDE offered such action – George Birbilis Nov 03 '21 at 02:14

1 Answers1

2

You'll probably find it depends on the order of the items in the parent objects Children list. There are various functions for managing the children of an object:

public
    //Returns the component we are a child of, which may not be the immediate parent
    function GetParentComponent: TComponent; override;
    function HasParent: Boolean; override;
    procedure AddObject(const AObject: TFmxObject);
    procedure InsertObject(Index: Integer; const AObject: TFmxObject);
    procedure RemoveObject(const AObject: TFmxObject); overload;
    procedure RemoveObject(Index: Integer); overload;
    function ContainsObject(AObject: TFmxObject): Boolean; virtual;
    procedure Exchange(const AObject1, AObject2: TFmxObject); virtual;
    procedure DeleteChildren;
    function IsChild(AObject: TFmxObject): Boolean; virtual;
    //Front and back (first and last) of Children list
    procedure BringToFront; virtual;
    procedure SendToBack; virtual;
    procedure AddObjectsToList(const AList: TFmxObjectList);
    procedure Sort(Compare: TFmxObjectSortCompare); virtual;
    property ChildrenCount: Integer read GetChildrenCount;
    property Children: TFmxChildrenList read FChildrenList;
    property Parent: TFmxObject read FParent write SetParent;
    //a.k.a. Parent.Children.IndexOf(Self)
    property Index: Integer read GetIndex write SetIndex; 
Mike Sutton
  • 4,191
  • 4
  • 29
  • 42