Use ScrollBars to control the scroll of an Image : ScrollBar « GUI « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » GUI » ScrollBar 
13. 12. 5. Use ScrollBars to control the scroll of an Image
Use ScrollBars to control the scroll of an Image
 


imports System
imports System.Drawing
imports System.Windows.Forms

public class ScrollBars : inherits Form

  dim pnl as Panel
  dim pb as PictureBox
  dim hbar as HScrollBar
  dim vbar as VScrollBar
  dim img as Image

  public sub New()
    Size = new Size(480,300)

    img = Image.FromFile("yourfile.jpg")

    pnl = new Panel()
    pnl.Parent = me
    pnl.Size = new Size(400,200)
    pnl.Location = new Point(10,10)
    pnl.BorderStyle = BorderStyle.FixedSingle

    pb = new PictureBox()
    pb.Parent = pnl
    pb.Size = new Size(img.Size.Width, img.Size.Height)
    pb.Location = new Point(00)
    pb.SizeMode = PictureBoxSizeMode.CenterImage
    pb.Image = img

    hbar = new HScrollBar()
    hbar.Parent = me
    hbar.Location = new Point(pnl.Left, pnl.Bottom + 25)
    hbar.Size = new Size(pnl.Width, 25)
    hbar.Minimum = 0
    hbar.Maximum = 100
    hbar.SmallChange = 1
    hbar.LargeChange = 10
    hbar.Value = 10
    AddHandler hbar.ValueChanged, AddressOf hbar_OnValueChanged

    vbar = new VScrollBar()
    vbar.Parent = me
    vbar.Location = new Point(pnl.Right + 25, pnl.Top)
    vbar.Size = new Size(25, pnl.Height)
    vbar.Minimum = 0
    vbar.Maximum = 100
    vbar.SmallChange = 1
    vbar.LargeChange = 10
    vbar.Value = CType((vbar.Maximum - vbar.Minimum2, integer)
    AddHandler vbar.ValueChanged, AddressOf vbar_OnValueChanged
  end sub  '  close for constructor

  private sub hbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
    pb.Location = new Point(CType((pnl.Size.Width - img.Size.Width* _
      hbar.Value /(hbar.Maximum - hbar.LargeChange + 1), integer), _
      pb.Top)
  end sub

  private sub vbar_OnValueChanged(ByVal sender as object,ByVal e as EventArgs)
    pb.Location = new Point(pb.Left, _
      CType((pnl.Size.Height - img.Size.Height* _
      vbar.Value / (vbar.Maximum - vbar.LargeChange + 1), integer))
  end sub

  public shared sub Main() 
    Application.Run(new ScrollBars())
  end sub

end class

        
13. 12. ScrollBar
13. 12. 1. Scroll Bar scrolls and get its current valueScroll Bar scrolls and get its current value
13. 12. 2. Value change event: Verical/Horizontal scroll barValue change event: Verical/Horizontal scroll bar
13. 12. 3. Use ScollBar to control font sizeUse ScollBar to control font size
13. 12. 4. Use ScrollBar to control the image scroll in a PictureBoxUse ScrollBar to control the image scroll in a PictureBox
13. 12. 5. Use ScrollBars to control the scroll of an ImageUse ScrollBars to control the scroll of an Image
w___ww__.__ja_v_a2___s.___c_o___m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.