Click here to Skip to main content
15,885,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am a beginner of vb.net
i wanna use hscrollbar to increase a image size
what can i do ? :omg:
Posted
Comments
PSK_ 20-Jun-10 10:58am    
You are talking about windows or web?

1 solution

VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
            HScrollBar1.Maximum = PictureBox1.Image.Width - _
            PictureBox1.Width + HScrollBar1.Height
            VScrollBar1.Maximum = PictureBox1.Image.Height - _
            PictureBox1.Height + VScrollBar1.Width
            VScrollBar1.Enabled = True
            HScrollBar1.Enabled = True
            If PictureBox1.Height > PictureBox1.Image.Height Then
                VScrollBar1.Enabled = False
            End If
            If PictureBox1.Width > PictureBox1.Image.Width Then
                HScrollBar1.Enabled = False
            End If
        End If
    End Sub

VB
Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll
        Dim gph As Graphics = PictureBox1.CreateGraphics
        gph.DrawImage(PictureBox1.Image, New Rectangle(0, 0, PictureBox1.Width - HScrollBar1.Height, _
        PictureBox1.Height - VScrollBar1.Width), _
        New Rectangle(HScrollBar1.Value, VScrollBar1.Value, _
        PictureBox1.Width - HScrollBar1.Height, _
        PictureBox1.Height - VScrollBar1.Width), GraphicsUnit.Pixel)
    End Sub


VB
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
        Dim gph As Graphics = PictureBox1.CreateGraphics
        gph.DrawImage(PictureBox1.Image, New Rectangle(0, 0, PictureBox1.Width - HScrollBar1.Height, _
        PictureBox1.Height - VScrollBar1.Width), _
        New Rectangle(HScrollBar1.Value, VScrollBar1.Value, _
        PictureBox1.Width - HScrollBar1.Height, _
        PictureBox1.Height - VScrollBar1.Width), GraphicsUnit.Pixel)
    End Sub
 
Share this answer
 
v2
Comments
Sandeep Mewara 21-Jun-10 8:18am    
Reason for my vote of 1
What is it? Answer is as unclear as the question was!
Smithers-Jones 21-Jun-10 9:01am    
Just throwing some crumbs of code isn't a sensible answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900