Solved

Setting runtime form location

Posted on 2016-11-21
4
41 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 34

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

Independent Software Vendors: 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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

729 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