Results 1 to 3 of 3

Thread: [2005] Scrolling a control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    17

    [2005] Scrolling a control

    I am using a control that is used to display images.

    I use this technique to paint images on my control
    2005 Code:
    1. Private Sub MultipleImageDisplayer_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    2.  
    3. Dim bmp As New System.Drawing.Bitmap("C:\image.jpg")
    4.  
    5. e.Graphics.DrawImage(bmp, 0, 0)
    6.  
    7. End Sub

    The problem is that the size of the control is 300 x 300 and the image's size is 1024 x 768. Hence only a portion of the image is visible.
    Even when autoscroll bar property of control is activated the scroll do not appear. I want to know how to add scroll bars to my control.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Scrolling a control

    Does your control inherit, either directly or indirectly, the ScrollableControl class? If not then it won't support auto-scrolling at all. That said, auto-scrolling only applies to child controls that are located outside the parent's view-port. You're using GDI+ to draw those images so auto-scrolling would not be relevant.

    You need to add HScrollBar and VScrollBar controls to your control, then handle the logic to redraw the images as required when the user scrolls. Alternatively you could add a Panel to your control and make it as big as is required to fit all the images on. Your control would then auto-scroll if the Panel was larger than the view-port. Both of these options assume that you've derived your control from UserControl.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2007
    Posts
    17

    Re: [2005] Scrolling a control

    Oh i never thought of it! thanks man

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width