Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I create a variable width label? 1

Status
Not open for further replies.

agc1976

Programmer
May 2, 2001
36
0
0
PR
Is it possible to vary the width of a label depending on its text width?

I want my labels to look like hyperlinks but the text inside those labels will vary sometimes and I want the MouseOver effect to only run when the mouse is over the visible part of the label.

I am using Access 97.
 
Hmmmmmmmmm,

Ignoring the part NOT in the subject line:

No. But you could re-size it dynamically.

Consider the somewhat obviously contrived example:

Code:
Private Sub chkA_C_Click()

    If Me.lblAc.Caption = "Air Conditioning" Then
        Me.lblAc.Caption = "Central Air Conditioning"
     Else
        Me.lblAc.Caption = "Air Conditioning"
    End If

    Me.lblAc.Width = (Len(Me.lblAc.Caption) * 72) * 1.1

End Sub
[code]

The "Caption" property of the label is actually the "Text" of the label.  The Width property is the width (here it is in PIXELS). The "Constant" value (72 here) is the pixels per character for the font / size (here it is Tahoma 8pt).  The "constant" (Here 1.1) just provides a 'comfort zone' space, so that it is aparent that the Caption is not truncated.

Again, this contrived example DOES NOT have the various V&V /error checking.  At a minium, you need to check the control (in it's entireity) remains within the container (Form/subform/tabPage ... ).  It would ALSO be "nice" to see that it did NOT intrude into another controls "space".

 MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top