Home All Groups Group Topic Archive Search About

Setting Label zorder above picture control

Author
31 May 2005 12:38 AM
jim
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

Author
31 May 2005 1:04 AM
Bob Butler
"jim" <edasich@nooo.spam.yahoo.com> wrote in message
news:uHtISkXZFHA.228@TK2MSFTNGP12.phx.gbl
> 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..."
Author
31 May 2005 1:08 AM
Larry Serflaten
"jim" <edasich@nooo.spam.yahoo.com> wrote
> 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
Author
31 May 2005 1:09 AM
Casey Provance
> 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
Author
31 May 2005 1:23 AM
Rick Rothstein
> > 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
Author
2 Jun 2005 1:55 PM
jim
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!
Author
2 Jun 2005 2:41 PM
Rick Rothstein
> 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