|
-
Oct 9th, 2002, 01:55 PM
#1
Thread Starter
Frenzied Member
Cannot control List Box Height???
There seems to be some problem with Run-time control of the Height of a List Box.
lboxText.Height = X does not work for all values of X
At least that what seems to happen. When I had a problem with an application, I made up the following Test Code.
VB Code:
Private Sub cmdHeight_Click()
Dim J As Integer
Dim Tally As Integer
lboxTest.Font = "MS Sans Serif"
lboxTest.FontBold = True
lboxTest.FontSize = 10
lboxTest.Clear
lboxA.Clear
lboxB.Clear
Tally = -200
For J = 100 To 2000
lboxTest.Height = J
If lboxTest.Height = J Then
lboxA.AddItem CStr(J) & " / " & CStr(lboxTest.Height)
Else
lboxB.AddItem CStr(J) & " / " & CStr(lboxTest.Height)
End If
'Tally = Tally + 1
'If Tally > 0 Then
'Exit Sub
'End If
Next J
End Sub
The above uses a Form with a Command Button (cmdHeight), and three List Boxes: lboxTest, lboxA, & lboxB. It attempts to set the Height of the Test List Box. The results of the attempts are recorded in two other List Boxes: One showing successful attempts and one showing situations for which the height was not set as specified.
I was astonished when I ran the above and examined the contents of List Boxes A & B.
Did I do something wrong? Am I misunderstanding something simple? Has anybody else encountered a similar situation?
The results vary depending on the Font parameters for lboxTest.
For my application, I wanted to change the height of a List Box depending on how many items were to be put into it. To identify each item in the List Box, I wanted to put Labels on the form to the left of the List Box.
To do the above required precise run-time control of the height of the list Box. which does not seem to be possible.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Oct 9th, 2002, 01:57 PM
#2
So Unbanned
It snaps.
Easiest way to explain it.
-
Oct 9th, 2002, 02:09 PM
#3
-= B u g S l a y e r =-
could it be the IntegralHeight property that is set to true and not false that causes this ?
-
Oct 9th, 2002, 02:11 PM
#4
PowerPoster
Height of a Listbox depends on current font height. Try using this snippet code and let me know:
VB Code:
Private Sub Form_Load()
'=======================
Dim i%, h%
Me.Show
Me.Font = List1.Font
h = Me.TextHeight("A")
For i = 0 To 9
List1.AddItem "Item " & i
List1.Height = h * (i + 1)
Next i
End Sub
-
Oct 9th, 2002, 02:12 PM
#5
PowerPoster
Note: Me.Show presents for debugging only.
-
Oct 9th, 2002, 02:35 PM
#6
PowerPoster
Are we done with this? If yes then chage topic to "Resolved".
-
Oct 9th, 2002, 09:29 PM
#7
Thread Starter
Frenzied Member
The IntegralHeight property seems to allow fine control of List Box height, although there seems to be some minimum height which is about 25% larger the height of a text string.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|