|
-
Jan 29th, 2007, 04:43 PM
#1
Thread Starter
PowerPoster
Is there a way to add a scroll bar to a list of command buttons?
Is there a way to add a scroll bar to a list of command buttons? OR is there a way to have a long list of items and you can scroll through them and then click on the one you want? Thanks guys.
-
Jan 29th, 2007, 04:53 PM
#2
Re: Is there a way to add a scroll bar to a list of command buttons?
Listbox
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jan 29th, 2007, 05:14 PM
#3
Thread Starter
PowerPoster
Re: Is there a way to add a scroll bar to a list of command buttons?
thanks, so if i had a list box full of things to click on, if i click on something on the list box, an textfile relating to that thing could open in a text box?
I mean, what would be a simple code, to load a bunch of names from a textfile into the listbox.
like
OptionA
OptionB
OptionC
etc..
I've done it with splitting it up into 2 or 3 groups, but for a single word per line i forget how to do.
Last edited by Justin M; Jan 29th, 2007 at 05:18 PM.
-
Jan 29th, 2007, 07:25 PM
#4
Re: Is there a way to add a scroll bar to a list of command buttons?
Load names from text file to listbox:
VB Code:
Dim TextFile As String
Dim Item As String
TextFile = "MyFile.txt"
Open TextFile For Input As #1
Do Until EOF(1)
Line Input #1, Item
List1.AddItem Item
Loop
Close #1
-
Jan 29th, 2007, 08:32 PM
#5
Re: Is there a way to add a scroll bar to a list of command buttons?
Yes if you put the Command buttons on a PictureBox then scroll the PictureBox with the scrollbar. Do a search there are plenty of examples on here.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
-
Jan 29th, 2007, 09:50 PM
#6
Thread Starter
PowerPoster
Re: Is there a way to add a scroll bar to a list of command buttons?
thanks i found something simular
 Originally Posted by iPrank
Add 3 command buttons, a HScrollbar a VScrollbar and a picturebox in the form.
Rename the picturebox to picContainer
Add another picturebox (Picture1) inside picContainer.
Set Picture1's Borderstyle=None and Appearance=Flat.
VB Code:
Option Explicit
Private Sub Command1_Click()
Picture1.Picture = LoadPicture("C:\SmallPic.jpg")
SetScrollBars
End Sub
'-----------------------------------------------------------------
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("C:\LargePic.jpg")
SetScrollBars
End Sub
'-----------------------------------------------------------------
Private Sub Form_Load()
'[b]You can set these at designtime[/b]
Me.ScaleMode = vbPixels
picContainer.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
HScroll1.Move picContainer.Left, _
picContainer.Top + picContainer.Height, _
picContainer.Width
VScroll1.Move picContainer.Left + picContainer.Width, _
picContainer.Top, _
VScroll1.Width, _
picContainer.Height
With Picture1
Set .Container = picContainer
.AutoSize = True
.Top = 0
.Left = 0
End With
Command1.Caption = "Load Small Picture"
Command2.Caption = "Load Large Picture"
With Command3
.Caption = ""
.Enabled = False
.Move VScroll1.Left, HScroll1.Top, VScroll1.Width, HScroll1.Height
End With
End Sub
'-----------------------------------------------------------------
Private Sub VScroll1_Change()
Picture1.Top = VScroll1.Value * -1
End Sub
'-----------------------------------------------------------------
Private Sub VScroll1_Scroll()
Picture1.Top = VScroll1.Value * -1
End Sub
'-----------------------------------------------------------------
Private Sub HScroll1_Change()
Picture1.Left = HScroll1.Value * -1
End Sub
'-----------------------------------------------------------------
Private Sub HScroll1_Scroll()
Picture1.Left = HScroll1.Value * -1
End Sub
'-----------------------------------------------------------------
Private Sub [b]SetScrollBars[/b]()
HScroll1.Value = 0
If Me.ScaleX(Picture1.Picture.Width, vbHimetric, vbPixels) > picContainer.ScaleWidth Then
HScroll1.Enabled = True
HScroll1.Max = Picture1.Width - picContainer.Width
Else
HScroll1.Enabled = False
End If
'
VScroll1.Value = 0
If Me.ScaleX(Picture1.Picture.Height, vbHimetric, vbPixels) > picContainer.ScaleHeight Then
VScroll1.Enabled = True
VScroll1.Max = Picture1.Height - picContainer.Height
Else
VScroll1.Enabled = False
End If
End Sub
Or if you are bored, try this.
.
this is simular to what im doing ,but i dont want no picture and to be honest there will be MANY command buttons, do i make a picture box and put the scroll bar on the side of it on the inside of it, or outside?
And this is a stupid qurstion but who do i make it work? I never used a scroll bar before
would be be something like this
VB Code:
Private Sub VScroll1_Change()
Picture1.Top = VScroll1.Value * -1
End Sub
'---------
-
Jan 30th, 2007, 05:35 AM
#7
Thread Starter
PowerPoster
Re: Is there a way to add a scroll bar to a list of command buttons?
on a side note, is there a limit to the height of a picture box? because i have 1 inside another and everytime i set its height to 40000 i get an over flow error.
-
Jan 30th, 2007, 06:03 AM
#8
Thread Starter
PowerPoster
Re: Is there a way to add a scroll bar to a list of command buttons?
Nevermind I got that fixed, but now i have a problem, when i scroll down, i cant see all of the buttons i put on there. Can this be adjusted? Thanks
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
|