Hello lopp2022,
if the new view object is not yet added to GUI component, use the method AddBehind( newView, oldView ). Then remove the old view from the component. If the view is already part of the GUI component, you can rearrange its position by using RestackBehind( theView, oldView ). Again, you do this before you remove the old view.
From your question I understood the views are managed by an Outline Box. Thus don't forget to set property Embedded of the new view before you add it to the component. Following could be a code sample:
// The old view you plan to replace
var Core::View oldView = ...
// Let's assume the new view should be a rectangle view
var Views::Rectangle newView = new Views::Rectangle;
// Ensure the new view will be managed by outline box.
newView.Embedded = true;
// Also configure other properties of the view (e.g. color, etc.)
newView.Bounds.size = <100,100>;
newView.Color = #FF0000FF;
// Add the new view just behind the old view
AddBehind( newView, oldView );
// Remove the old view
Remove( oldView );
For more details concerning the both methods please see the chapter Compose the component programmatically. See also the section Enumerate and search views controlled by the Outline Box if you need to find the old view before you add a new view.
I hope it helps you further.
Best regards
Paul Banach