Board index » Visual Studio » Setting Label zorder above picture control

Setting Label zorder above picture control

Visual Studio20
How can I keep a label above a picture (control), without making it a

container of the picture? Otherwise the label always gets covered by the

picture control regardless of the label's zorder that I set.

thanks


-
 

Re:Setting Label zorder above picture control



"jim" <edasich@nooo.spam.yahoo.com>wrote

Quote
How can I keep a label above a picture (control), without making it a

container of the picture? Otherwise the label always gets covered by the

picture control regardless of the label's zorder that I set.

thanks



You might use a textbox. But, why can't the lable be on the picturebox?



LFS

-

Re:Setting Label zorder above picture control

"jim" <edasich@nooo.spam.yahoo.com>wrote in message

Quote
How can I keep a label above a picture (control), without making it a

container of the picture? Otherwise the label always gets covered by

the picture control regardless of the label's zorder that I set.



You can't. Labels aren't separate windows; they are drawn directly onto

their container. You can use a textbox and set the properties so that it

looks like a label or you can change the label's container.



--

Reply to the group so all can participate

VB.Net: "Fool me once..."



-

Re:Setting Label zorder above picture control

Quote
You might use a textbox. But, why can't the lable be on the picturebox?



A label is considered a "lightweight" or "windowless" control with no window

handle and all the perks that come with. Lighter on system resources, etc,

etc.



- Kev





-

Re:Setting Label zorder above picture control

Quote
>You might use a textbox. But, why can't the lable be on the

picturebox?



A label is considered a "lightweight" or "windowless" control with no

window

handle and all the perks that come with. Lighter on system resources,

etc,

etc.



Larry knows that... he meant "situated on (or in)" the PictureBox; not

"on top of" the PictureBox.



Rick - MVP



-

Re:Setting Label zorder above picture control

Thanks for replies and sorry for late response. My need for using the

label was based on having a large array of image controls and I just wanted

to superimpose a single word "TEST" across only one image (with varying

index) of the control array. It was only a hassle to make a label inside

every container for every image control instead of making do with just one.

AND curious people just want to know!





-

Re:Setting Label zorder above picture control

Quote
Thanks for replies and sorry for late response. My need for using

the

label was based on having a large array of image controls and I just

wanted

to superimpose a single word "TEST" across only one image (with

varying

index) of the control array. It was only a hassle to make a label

inside

every container for every image control instead of making do with just

one.

AND curious people just want to know!



Your statement above is confusing. You say you have a large array of

image controls, but that it is a hassle to make a label inside every

container. The Image Control (not PictureBox) is NOT a container; you

can just move the Label control to the center of the Image Control like

this



Label1.Move (Image1.Width - Label1.Width) / 2, _

(Image1.Height - Label1.Height) / 2



and follow that with



Label1.ZOrder



to make sure the Label Control is visibly on top of the Image Control.

However, if you are using the term "image control" loosely and, in fact,

mean you have a control array of PictureBoxes (these CAN be a container

for other controls), then you can still use a single Label control and

move it inside the PictureBox using its own Container property. Here is

a Sub that will do that (assuming default names for your controls;

change them in the code to match what you have named your own controls)



Sub MoveLabel(PBoxIndex As Long)

Set Label1.Container = Picture1(PBoxIndex)

Label1.Move (Picture1(PBoxIndex).ScaleWidth - Label1.Width) / 2, _

(Picture1(PBoxIndex).ScaleHeight - Label1.Height) / 2

End Sub



Just call the MoveLabel subroutine and pass in the Index number of the

Picture1 control array of PictureBox Controls that you want to place the

Label Control in and it will appear centered inside the PictureBox with

that Index value.



Rick - MVP



-