Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 7th, 2006, 09:44 AM
Registered User
 
Join Date: Mar 2006
Location: Ahmedabad, Gujarat, India.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Resizing controls in a ScrollableForm Layout Event

Hi friends,

I was working on a form that listed a set of images(up to around 500 images).
I wanted the form to be scrollable and resize images to maintain their width to the form's width and set the height to match the 4:3 ratio and change them on layout event.
So i wrote the following code.

Code:
Class ABC
    Inherits Form
    Private Sub ABC_Layout(ByVal sender As Object, ByVal e As System.Windows.Forms.LayoutEventArgs) Handles Me.Layout
        Dim W As Integer, H As Integer, M As Integer
        Dim i As Integer = 0

        M = 20 ' Margin
        W = ClientSize.Width - (M * 2)
        H = CInt(W * 3D / 4D) ' 500

        For Each Ctrl As Control In Me.Controls
            Ctrl.Location = New Point(M + AutoScrollPosition.X, (i * (H + M)) + AutoScrollPosition.Y)
            Ctrl.Size = New Size(W, H)
            i += 1
        Next
    End Sub

    Private Sub ABC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim W As Integer, H As Integer, M As Integer
        M = 20 ' Margin
        W = ClientSize.Width - (M * 2)
        H = CInt(W * 3D / 4D) '500
        Me.AutoScroll = True
        Me.AutoScrollMargin = New Size(M, M)
        For i As Integer = 0 To (500 - 1)
            Dim NewPicture As New PictureBox
            NewPicture.Location = New Point(M + AutoScrollPosition.X, (i * (H + M)) + AutoScrollPosition.Y)
            NewPicture.Size = New Size(W, H)
            NewPicture.BorderStyle = BorderStyle.FixedSingle
            NewPicture.Name = "Picture #" & (i + 1).ToString
            NewPicture.ImageLocation = "Image" & (i + 1).ToString & ".jpg"
            NewPicture.SizeMode = PictureBoxSizeMode.StretchImage
            Me.Controls.Add(NewPicture)
        Next
    End Sub
End Class
the problem is (wether i set AutoScrollMinSize manually or not),
the images overlap each other after some point.
that is in my test, images are around 1024x768 resolution,
so after around image # 45 in all the images Control.Location.Y property remains the same(or what).
so after i scroll down to end of vertical scroll, i get image# 45. All other after it are hidden behind it. I hope u guys can understand it.

If u can't get the problem, u simply paste the given code in IDE and first guess the results and then see the actual results.

Please help me.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resizing the controls AccessAasif@aol.com C# 1 December 12th, 2007 05:25 AM
Raise Event From Dynamic Controls netwizard_01 ASP.NET 1.0 and 1.1 Basics 1 August 3rd, 2006 06:50 AM
Event creation for dynamically created controls sk80 Pro VB 6 2 February 7th, 2006 07:55 AM
Is there an Event for resizing the main XL window? labdad Excel VBA 2 January 6th, 2006 07:23 PM
buggy event firing in ActiveX controls pgtips Pro VB 6 6 July 10th, 2003 02:38 AM



All times are GMT -4. The time now is 02:00 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.