Solved

Setting runtime form location

Posted on 2016-11-21
4
38 Views
Last Modified: 2016-11-21
hello,
How can I set location of the runtime created form below the mainform.
I have 5 runtime forms ,they need to be one below the other when created.


i have this bit of working vcode:

objfrm2 .Location = New Point(Me.Left, Me.Bottom + objFrm2.Height)

The 'Me' should be the last created form or the mainform ,need advise on the 'Me' part
Cheers
0
Comment
Question by:RIAS
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
ste5an earned 250 total points
ID: 41895808
Use an director (see builder pattern). E.g. something like:

Public Class WindowManager
    Private forms As New List(Of Form)

    Public Sub AddForm(AForm As Form)
        Me.forms.Add(AForm)
    End Sub

    Public Sub ArrangeWindows()
        Dim currentTop As Long = 0

        For Each form As Form In Me.forms
            form.Location = New Point(form.Left, currentTop)
            currentTop += form.Height
        Next form
    End Sub
End Class

Open in new window

0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 250 total points
ID: 41895828
Me refers to the object the code is being run in.  eg.  The current instance of a form.  

Other objects would need to be qualified with code   eg.  frm1.xxxx, frm2.yyyy where frm1, frm2 are references to existing forms.
0
 

Author Comment

by:RIAS
ID: 41895857
Hello,
This is the code :

 Dim objFrm2 As New FrmInvoices(AddrowinForm, True)

            Me.StartPosition = FormStartPosition.Manual

            'Me.Location = New Point(30,
            '30)  'Screen.GetWorkingArea(Me).Location
            Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) \ 2, 0)

            With objFrm2
                .StartPosition = FormStartPosition.Manual
                'Select Case StrPosition
                'Case 1
                If IntLocationBase = 0 Then

                    .Location = New Point(Me.Left, Me.Bottom + objFrm2.Top)
                    IntLocationBase = Me.Bottom + objFrm2.Height-----Need help here

                Else
                    .Location = New Point(Me.Left, IntLocationBase + objFrm2.Height) ------Need help here
                    IntLocationBase += objFrm2.Height -----Need help here
                End If
                .Show()
            End With

Open in new window

0
 

Author Closing Comment

by:RIAS
ID: 41895866
Cheers#!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question