[AccessD] Adjust Label width based on caption

Stuart McLachlan stuart at lexacorp.com.pg
Mon Jan 23 15:55:02 CST 2012


If you include  Lebans'  code at 
http://www.lebans.com/textwidth-height.htm 
you can do it more accurately with something like this:

Dim lngTemp As Long
lblTest.Caption = "ABCDEFGHIJKLMNOP"
lngTemp = fTextWidth(lblTest) + 100
lblTest.Width = lngTemp
lblTest2.Left = lblTest.Left + lngTemp


<quote>TextHeightWidth.zip is a replacement for the Report object's TextWidth and 
TextHeight methods. It is multiline aware and can work in both Report and Form views. 
Includes a sample report to show you how to autosize individual controls with different 
formatting on the same line to simulate RTF style text.</quote>

-- 
Stuart

On 23 Jan 2012 at 13:15, David McAfee wrote:

> I ended up doing this:
> 
> 
> Me.lblHistory.Width = ((Len(trim(Me.lblHistory.Caption)) * 107) + 25)
> Me.lblAlert.Left = (Me.lblHistory.Width + 125)
> 
> Works good!
> 
> David
> 
> On Mon, Jan 23, 2012 at 12:20 PM, David McAfee <davidmcafee at gmail.com>wrote:
> 
> > I have two labels.
> >
> > One (lblHistory) has text which can vary in length.
> >
> > I have another label (lblAlert), to the right on lblHistory which, under
> > certain conditions, may be set to be visible, Red or Black and bold or non
> > bold.
> >
> > I'd have lblAlert butted up next to lblHistory, but if the length of the
> > text is short, it doesn't look right.
> >
> > I can figure out how to position the 2nd label, but at the moment I can't
> > decide how to "trim" the label length.
> >
> > Any ideas?
> >
> > David
> >
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 

--
Stuart McLachlan

Ph:    +675 340 4392 
Mob: +675 7100 2028
Web: http://www.lexacorp.com.pg



More information about the AccessD mailing list