mkdjo
asked on
scrollbar
I have a form, which dynamic changes its size. Sometimes I have two lines of textboxes, and sometimes I have 200 lines of textboxes. Now I want to add a scrollbar to the form, which is always as large as the form itself. I mean, I want to connect the height of the scrollbar to the height of the form, so I can scroll down the form.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The resize event changes whenever the form size changes.. Either through the user changing the form's size, or through the form's properties and methods. Setting Form1.Height, and Form1.Width will fire the Resize event, as well as calling Form1.Move (with the height and/or width parameters).
(of course replace Form1 with the actual name of your form).
Remember, you never want to change the form size to larger than the screen, if you do, you won't be able to scroll it. This is the purpose of the picturebox. It can be larger than the form and be able to be scrolled.
Also, if you are creating Textboxes "on the fly", you may have to set the Container property of the textbox to the picture control for the above code to work properly.
(of course replace Form1 with the actual name of your form).
Remember, you never want to change the form size to larger than the screen, if you do, you won't be able to scroll it. This is the purpose of the picturebox. It can be larger than the form and be able to be scrolled.
Also, if you are creating Textboxes "on the fly", you may have to set the Container property of the textbox to the picture control for the above code to work properly.
ASKER
You wrote:
>>Also, if you are creating Textboxes "on the fly", you may have to set the Container >>property of the textbox to the picture
>> control for the above code to work properly.
How can I do this? I post my code.
Private Sub Form_Load()
n = 1
Dim h
For i = 1 To Form1.PNumber
Load vorgabe(n) Rem Name of textbox
vorgabe(n).Top = vorgabe(n - 1).Top + vorgabe(0).Height + 120
vorgabe(n).Visible = True
h = vorgabe(n).Top + vorgabe(n).Height + 120
Height = h + Height - ScaleHeight
n = n + 1
Next i
thanks for your help.
>>Also, if you are creating Textboxes "on the fly", you may have to set the Container >>property of the textbox to the picture
>> control for the above code to work properly.
How can I do this? I post my code.
Private Sub Form_Load()
n = 1
Dim h
For i = 1 To Form1.PNumber
Load vorgabe(n) Rem Name of textbox
vorgabe(n).Top = vorgabe(n - 1).Top + vorgabe(0).Height + 120
vorgabe(n).Visible = True
h = vorgabe(n).Top + vorgabe(n).Height + 120
Height = h + Height - ScaleHeight
n = n + 1
Next i
thanks for your help.
Right after the line:
vorgabe(n).Visible = True
use this code:
set vorgabe(n).Parent = Picture1 'Or whetever you call it
Also, in the line:
Height = h + Height - ScaleHeight
You should be resetting the picture1.Height, not the form height.
And, since you have turned off the border, you won't need the ScaleHeight:
Picture1.Height = h + Picture1.Height
vorgabe(n).Visible = True
use this code:
set vorgabe(n).Parent = Picture1 'Or whetever you call it
Also, in the line:
Height = h + Height - ScaleHeight
You should be resetting the picture1.Height, not the form height.
And, since you have turned off the border, you won't need the ScaleHeight:
Picture1.Height = h + Picture1.Height
ASKER
Thank you, this works. But I don't use the
<< set vorgabe(n).Parent = Picture1 'Or whetever you call it
because my compiler don't know .parent. Resetting the picture1.height is it.
<< set vorgabe(n).Parent = Picture1 'Or whetever you call it
because my compiler don't know .parent. Resetting the picture1.height is it.
ASKER
thanks
Martin