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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ImageBox Resize Problem 1

Status
Not open for further replies.

Ashpoop1

Programmer
Jun 27, 2011
2
AU
Hi, I'm fairly new to visual basic and programming in general... i'm teaching myself quickly, but of course we run into little problems.

In a basic project, i have an imagebox with an image already loaded, a vertical scroll bar, and a label. When the user scrolls the scroll bar in the form, it must change the height of the image according to the value of the scroll bar and display the value in the label. So far i have:
_________________________________________________________________________
Public Class Form1
Private vsbSquirt As AccessibleObject
Private Sub vsbSquirt_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs)
lblHeight.Text = vsbSquirt.Value
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblHeight.Text = vsbSquirt.Value
End Sub
Sub ImageHeight(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgSquirt.SizeChanged
SetAttr(imgSquirt.Size(157, vsbSquirt.Value))
End Sub
End Class
_________________________________________________________________________

I'm not too sure how to tell the program to resize the image and i've been playing around for hours and hours slowly eliminating errors and reached this conclusion with only 1 error left... under "imgSquirt.Size" in the last Sub and reads: "structure 'system.drawing.size' cannot be indexed because it has no default property"

Any help or tips is greatly appreciated, thanks
 
Are you sure you want use AccessibleObject?
"Provides information that accessibility applications use to adjust an application's user interface (UI) for users with impairments." as per MSDN.

If you need only increase the height of the picturebox then try something like this
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With imgSquirt
            .Minimum = Me.PictureBox1.Height
            .Maximum = Me.PictureBox1.Height * 2
        End With
    End Sub


    Private Sub imgSquirt_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles imgSquirt.Scroll
        Me.PictureBox1.Height = imgSquirt.Value
        lblHeight.Text = imgSquirt.Value
    End Sub
where imgSuirt is a trackbar not scrollbar. If it was scrollbar then code will be
Code:
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        With Me.HScrollBar1
            .Minimum = Me.PictureBox1.Height
            .Maximum = Me.PictureBox1.Height * 2
        End With
    End Sub
    Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
        Me.PictureBox1.Height = HScrollBar1.Value
        lblHeight.Text = HScrollBar1.Value
    End Sub

Zameer Abdulla
 
Thanks for your help Abdulla...
Firstly, If i don't use accessible object, everywhere 'vsbSquirt' is written is underlined with blue and reads 'vsbSquirt is not declared. It may be inaccessible due to its protection level' and i have no idea how else to deal with this. Everything else makes sense and is a great help
 
You need to add reference to Accessibilty if you want to use it.
this may be causing the error.

Zameer Abdulla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top