2 new 2 b called newbie - scrollbar question
I'm not even sure if newbies can ask question in this group but here
goes....
I want to add a verticle scrollbar to a label. I need the user to be
able to scroll through text but still be able to view the form's
background image. I didn't think a text box would work for me since
transparency is not allowed for text box background color....so I
figured a label is my best bet. I just started learning vb.net this
week and can't figure out the freakin code to add a vscrollbar to a
label. Hell, I can't even get the picturebox example code I found in
the documentation to work. Please help! Does anyone have a SIMPLE
example of what I would like to do? And maybe you can point out why
this picturebox scroll example won't work for me either. And maybe
also why I don't have a brain in my head? Thanks.
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents HScrollBar1 As System.Windows.Forms.HScrollBar
Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar
<System.Diagnostics.De{*filter*}StepThrough()> Private Sub
InitializeComponent()
Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(Form1))
Me.Label1 = New System.Windows.Forms.Label()
Me.PictureBox1 = New System.Windows.Forms.PictureBox()
Me.VScrollBar1 = New System.Windows.Forms.VScrollBar()
Me.HScrollBar1 = New System.Windows.Forms.HScrollBar()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.ForeColor = System.Drawing.SystemColors.Info
Me.Label1.Location = New System.Drawing.Point(25, 20)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(130, 155)
Me.Label1.TabIndex = 4
Me.Label1.Text = "Label1"
'
'PictureBox1
'
Me.PictureBox1.Image =
CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Bitmap)
Me.PictureBox1.Location = New System.Drawing.Point(240, 30)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(125, 145)
Me.PictureBox1.TabIndex = 7
Me.PictureBox1.TabStop = False
'
'VScrollBar1
'
Me.VScrollBar1.Location = New System.Drawing.Point(350, 30)
Me.VScrollBar1.Name = "VScrollBar1"
Me.VScrollBar1.Size = New System.Drawing.Size(15, 145)
Me.VScrollBar1.TabIndex = 8
'
'HScrollBar1
'
Me.HScrollBar1.Location = New System.Drawing.Point(240, 160)
Me.HScrollBar1.Name = "HScrollBar1"
Me.HScrollBar1.Size = New System.Drawing.Size(110, 16)
Me.HScrollBar1.TabIndex = 9
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(467, 228)
Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.HScrollBar1, Me.VScrollBar1, Me.PictureBox1, Me.Label1})
Me.ForeColor = System.Drawing.SystemColors.Info
Me.Name = "Form1"
Me.Text = "scrolleg"
Me.ResumeLayout(False)
End Sub
#End Region
Public Sub SetScrollBarValues()
' Set Maximum to the size of the Image, Minimum to zero.
VScrollBar1.Maximum = PictureBox1.Image.Height
HScrollBar1.Maximum = PictureBox1.Image.Width
HScrollBar1.Minimum = 0
VScrollBar1.Minimum = 0
' Set LargeChange to the size of the PictureBox
' minus the scroll_bar.
VScrollBar1.LargeChange = PictureBox1.Height -
HScrollBar1.Height
HScrollBar1.LargeChange = PictureBox1.Width -
VScrollBar1.Width
' Set five SmallChanges per LargeChange.
VScrollBar1.SmallChange = _
System.Convert.ToInt32(VScrollBar1.LargeChange / 5)
HScrollBar1.SmallChange = _
System.Convert.ToInt32(HScrollBar1.LargeChange / 5)
' Initially display the upper-left corner of the image.
VScrollBar1.Value = 0
HScrollBar1.Value = 0
End Sub
End Class