|
-
Dec 15th, 2007, 10:52 PM
#1
Thread Starter
Junior Member
[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:
Private Sub MultipleImageDisplayer_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim bmp As New System.Drawing.Bitmap("C:\image.jpg")
e.Graphics.DrawImage(bmp, 0, 0)
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.
-
Dec 15th, 2007, 11:12 PM
#2
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.
-
Dec 16th, 2007, 10:20 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|