Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 48
  • Last Modified:

Setting runtime form location

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
RIAS
Asked:
RIAS
  • 2
2 Solutions
 
ste5anSenior DeveloperCommented:
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
 
AndyAinscowCommented:
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
 
RIASAuthor Commented:
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
 
RIASAuthor Commented:
Cheers#!
0

Featured Post

Technology Partners: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now