Placing A Label Over A Userform Control

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,616
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a label (label8) that I am trying to position at a certain point of my userform.

Code:
        With .Label8
            .Top = 36
            .Left = 92
        End With

The issue I am having, is this move puts the label behind a locked listbox control. This is the intended location, but I'd like to put the label on top of this control.

Can it be done?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Select the label, Top menu....Format...Order(all the way at the bottom)...Bring to front.

By the way, if you're just trying to "hide" the textbox, you can just make it invisible ...or:

TextBox1.Visible = False 'or True

and then make it visible whenever you're ready...much easier....IF that's what you're trying to accomplish :) ...not that I'm speculating lol.
 
Last edited:
Upvote 0
Thanks jproffer ...
No ... I'm not wanting to hide the underlying listbox. It still needs to be visible to some extend, although inaccessible.
Can the order suggestion you mention be coded?
 
Upvote 0
What do you mean inaccessible? Labels are not clickable anyway.

Good code Dom...never heard of the ZOrder property...I'll have to keep that in my pocket :)
 
Upvote 0
When I try this the Label is not visible. After using this script on Userform Open
Code:
Private Sub UserForm_Initialize()
Me.Label1.ZOrder 0
Now if I put a Textbox over top of the label the label is still visible.
But this does not work when a ListBox is put over a label.
This is when using UserForm controls.
 
Upvote 0
Thanks all for your support.

jproffer ... you asked and stated "What do you mean inaccessible? Labels are not clickable anyway."
It's not the label that's "inaccessible". Its the underlying listbox that I'm trying to superimpose the label over which is inaccessible. I know labels aren't clickable. This listboxe is locked, making the control basically nonfunctional.

Domenic ... I'm afraid that the bug may be biting again. I tried, but no luck unless I've coded that wrong.

This asthetic task I'm trying to accomplish would be so much more simple if only labels (and other controls) had a vertical alignment property. I would simply make a label with the same physical qualities (size, etc) as the listbox control, hide the listbox and move the label to where the listbox is (hidden). Looks like the original listbox, but isn't. It's a simple label with simple text centred in it. The hurdle is, I can only get it centred horizontally.

It's very early, so maybe I'm missing something simple and obvious.

This is what I'm trying to accomplish...

 
Last edited:
Upvote 0
I have been experimenting with a concept mentioned above ... about hiding thelistbox and replacing it with a mimicking label. (knowing it's not exactly what I am wanting)

Code:
        With .uf1_listbox2
            '.Clear
            .ForeColor = RGB(0, 52, 89)
            .ColumnCount = 2
            .ColumnWidths = "75;25"
            .List = Range("redundancy_list").Value
            .ListStyle = fmListStyleOption
            .ListStyle = fmListStylePlain
            .MultiSelect = fmMultiSelectSingle
            .Visible = False
        End With
        
        With .Label8
            .Top = 12
            .Left = 78
            .ZOrder 0
        End With

This moves the label to the coordinates but with reference to the userform. The values I have were with reference to the frame within that userform that the label should reside.
What must I add to ensure that the left and top properties are with reference to frame103? Or do I need to determine the top and left values of the label only from within the userform scope?
 
Upvote 0
If the listbox properties are in relation to the frame, then the left of the frame + the left of the listbox in the frame = the left of the label in relation to the userform. Same for the top.

That will get you close. You'll have to "play" it and check it out...sometimes they're not exactly the same.
 
Upvote 0
This experiment failed. I made the listbox invisible and moved the label to the same position that the listbox was in the frame. But I'm guessing that the label is behind the frame. ZOrder didn't work any better in this situation than the previous.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top