On Dec 2, 2006, at 2:51 PM, bigbird wrote:
G'day Jack,
Alternately, you can write code to size and position your
StaticText controls based on content, using TextHeight and
StringWidth on the window's graphics or a Picture's graphics to
determine the requirements.
This is what I would like to do - I could manipulate the relative
positions of the StaticTexts. I have looked at the RB documentation
but can't see how to use the TextHeight and StringWidth to achieve
this - could you give me a quick example please?
dim ArrayOfLines() as string = Array("This is string1", "This is
string2", "This is string3", "This is string4", "This is string5",
"This is string6", "This is string7")
dim NumberOfLines as integer = UBound(ArrayOfLines) + 1
// Create a picture with same text properties as the static text
dim p as Picture = new Picture(1,1,16)
dim g as graphics = p.graphics
g.TextFont = StaticText1.TextFont
g.TextSize = StaticText1.TextSize
StaticText1.Height = NumberOfLines*g.TextHeight // set the height
// Put text in multiline statictext
dim i as integer
For i = 0 to NumberOfLines - 1
StaticText1.Text = StaticText1.Text + ArrayOfLines(i) + EndOfLine
Next
// Position the next one
StaticText2.Top = StaticText1.Top + StaticText1.Height + 5
StaticText2.Text = "Next"
Best
Jack
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>