I have a Frame containing other controls, and I have ListBox. All of these are within a Userform. Initially, the Frame is invisible, and there is a button which toggles its visibility. I want the Frame and its contents to appear in front the ListBox, however, this doesn't happen.
I've tried bringing the Frame to the front and sending the ListBox to the back using the Order part of the Format menu, but that hasn't changed anything. I added.
'Bring it to the front
DatePickerFrame.ZOrder (0)
'Send the ListBox to the back
SearchResultsListBox.ZOrder (1)
to my Userform's initialisation, which led to this when toggling the visibility of the Calendar Frame on:
but also led to this when toggling the visibility of the Calendar Frame off:
I also cut and paste this code into the button that toggles the Calendar's visibility, but it led to the same behaviour.
For some reason (I'm yet to figure out why), when you turn something visible while it overlaps something else, the overlap remains..
When clicking it again (overlap remains):
The code I used to play around with that finally worked to show only the listbox when putting the frame back to invisible:
Private Sub CommandButton2_Click()
Frame1.Visible = Not Frame1.Visible
ListBox1.Visible = False 'this is absolutely necessary
ListBox1.Visible = True
Frame1.ZOrder (IIf(Frame1.Visible, 0, 1)) 'needs to come after making the listbox (in)visible.
'ListBox1.ZOrder (IIf(Frame1.Visible, 1, 0)) 'not necessary since you want the frame to be in front
End Sub
If that's not the issue, let me know and I'll check some more :)