Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3798

Changing control's z-order

$
0
0

I was looking for a way to change the z-order of UI controls in a window but couldn’t find anything definitive. Here’s an example of how it can be done if anyone is still looking for a solution:

  1. Add three rectangles, maybe coloured white, red & blue, created in that order so the white is at back and blue at front. Make them overlap so you can see the change.
  2. Add a button to change order when pressed
  3. Add the following in the button’s ‘Pressed’ event. This should re-order the three rectangles so the white rectangle is at front. Sorry, I still haven’t worked out how to paste code in here :slight_smile:

var arrayRects() As DesktopRectangle

System.DebugLog(“— order before changes —”)
for each obj as Object in self.Controls
if obj IsA DesktopRectangle then
var strName As String = DesktopRectangle(obj).Name
System.DebugLog(strName)
arrayRects.Add(DesktopRectangle(obj)) // adding this rectangle to the array
end if
next

// removing all rectangles from window
for index as Integer = 0 to arrayRects.LastIndex
arrayRects(index).Close
next

// adding rectangles back to window in new order
self.AddControl(arrayRects(1))
self.AddControl(arrayRects(2))
self.AddControl(arrayRects(0))

System.DebugLog(“— order after changes —”)
for each obj as Object in self.Controls
if obj IsA DesktopRectangle then
var strName As String = DesktopRectangle(obj).Name
System.DebugLog(strName)
end if
next


4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 3798

Trending Articles