Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alternative to form scrolling? 1

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
0
0
US
I am new with VB and I just found out, the hard-way, that VB does not support form scrolling. As it is, my data entry form is 2 pages long with 100 controls (labels and text boxes). I am left with two alternatives - SSTAB Control and MDIform (which I know nothing about). Are these the only choices I've got?

With SSTAB, how do I drop the control inside each tabs, I tried to put some labels but it did not stick inside the tab, and the textbox that I created, remains visible to all the tabs. Is there a way that I can change the color of the tab?

Any help will be greatly appreciated.


 
Use this piece of code to scroll the form and change the value of MAX property to whatever u need

Let me know if it works :)
------------------------------------------------------------

Dim VPos As Integer

Private Sub VScroll1_Change()
Call ScrollForm(0)
End Sub

Private Sub VScroll1_Scroll()
Call ScrollForm(0)
End Sub

Public Sub ScrollForm(Direction As Byte)
Dim ctl As Control

'Scroll Vertically
If Direction = 0 Then
For Each ctl In Me.Controls
'Make sure it's not a ScrollBar
If Not (TypeOf ctl Is VScrollBar) Then
'If it's a Line then
If TypeOf ctl Is Line Then
ctl.Y1 = ctl.Y1 + VPos - VScroll1.Value
ctl.Y2 = ctl.Y2 + VPos - VScroll1.Value
Else
ctl.Top = ctl.Top + VPos - VScroll1.Value
End If
End If
Next
VPos = VScroll1.Value
End If
End Sub

------------------------------------------------------------
 
thanks lovehuman,

your code works perfectly!! My only problem now is that when I'm designing the form, the maximum height that I can set it(the form) to is 9000, it's like one page short of my data entry form. Is there a way around this? It would have been great if I can fit it all in one form and just scroll down.

thanks again!!!
 
The maximum value you can set for Scroll bar is 32767. Try using this piece of code

Private Sub Form_Load()
VScroll1.Max = 32767
End Sub

I hope I understand your question right? R u talking about form'e height or scroll bar's maximum value?
 
The form height. I tried changing it to a higher value, but it wouldn't take it.




 
You can change the height of the form at runtime by using following code in the form load event

Private Sub Form_Load()
VScroll1.Max = 32767
Form1.Height = 30000
End Sub
 
Hi Friend,


I don't know option for form scrolling but if u pur a control directly on any of the Tab of SSTAB then u r prob can be solved. The control directly dragged and dropeed on the tab is visible only on that tab. Click any control drag it to the tab and drop it.


bye :)
 
EdRev wrote:
"my data entry form is 2 pages long with 100 controls (labels and text boxes)"

I suggest you show a little mercy on your users and redesign the form into smaller parcels - perhaps with a tab control, to make it a little easier to overview... Then the scrolling problem will go away by itself...

Cy
 
thanks guys,

lovehuman, I want to set the height at design time and keep make it smaller at run-time so it can be consistent with all the forms in the application, I want the user to be able to scroll down and view the rest of the form.

i'm considering cyborg's suggestion to keep the data entry form in small parcels, using SSTAB, that is after i figure-out how it works.

betaanish, i tried to put some controls on one of the tabs.
the label control did not appear at all and the textbox persist on all the tabs. what am i doing wrong? can i change the background color( not the backcolor) of the tabs.

again, thank you all for your help.

 
I too found at the hard way, but the code offered up by lovehuman worked perfect for me.
 
Ed,

You are not creating the label or text box on the sstab control. Place the controls directly on the sstab control. If you place the controls on the form and then drag them on the sstab control, the control will be visible on all tabs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top