J
John T Ingato
I would like to format my form on the fly so that it looks as professional
as possible.
I am passing an list array to a form and filling a listbox with the array
items. I would like to make the listbox just big enough to completely hold
the text. Plus, I would like to center the listbox horizontally in the
form.
I have a proceedure that finds the longest text length in the list and then
set the list box width to the length of the string * fontsize:
fontsize = Me.listbox.Font.Size
With Me.listbox
.Top = Label1.Height + (Label2.Height * 2)
.Height = ( Me.listbox.ListCount ) * fontsize
.Width = Len(longestString) * fontsize
.Left = (frmPromptUser.Width - listbox.Width) / 2
End With
But the listbox is not high enough and it well too wide. Now I realize that
the width of each letter in a string is not as many point wide as is is high
and I also realize that the sum of the points of each item does not take
into account the separation between the items. Also the listbox is close...
but not centered. I have tried combinations of setting the autosize( not
available with a listbox) and integralHeight with no luck.
Any suggestions?
as possible.
I am passing an list array to a form and filling a listbox with the array
items. I would like to make the listbox just big enough to completely hold
the text. Plus, I would like to center the listbox horizontally in the
form.
I have a proceedure that finds the longest text length in the list and then
set the list box width to the length of the string * fontsize:
fontsize = Me.listbox.Font.Size
With Me.listbox
.Top = Label1.Height + (Label2.Height * 2)
.Height = ( Me.listbox.ListCount ) * fontsize
.Width = Len(longestString) * fontsize
.Left = (frmPromptUser.Width - listbox.Width) / 2
End With
But the listbox is not high enough and it well too wide. Now I realize that
the width of each letter in a string is not as many point wide as is is high
and I also realize that the sum of the points of each item does not take
into account the separation between the items. Also the listbox is close...
but not centered. I have tried combinations of setting the autosize( not
available with a listbox) and integralHeight with no luck.
Any suggestions?