dcsimg
Results 1 to 2 of 2
  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2011
    Posts
    114

    programmatically move child Form from parentMDI

    Hi guys,
    I Googled this a lot, and can't find the answer...
    I have a parent MDI and a child Form (Notes)
    I have set Notes to open on a specific location:
    Code:
            Dim x As Integer = (Me.Width - Notes.Width) - 19
            Dim f As New Notes
            If IsNotesOpen = Nothing Or 0 Then
                f.MdiParent = Me
                f.StartPosition = FormStartPosition.Manual
                f.Location = New Point(x, 0)
                f.Show()
                IsNotesOpen = 1
            End If
    (This will open Notes on the top right corner of the parent MDI - this works good)
    My problem is, I need the Notes form to stay at that position when the form is maximized or changed size...
    So I have this code:
    Code:
        Private Sub MDI_SizeChanged(sender As Object, e As EventArgs) Handles Me.SizeChanged
            If IsNotesOpen = 1 Then
                Notes.Location = New Point(Me.Width - Notes.Width - 19)
            End If
        End Sub
    But Notes doesn't move to the new location
    Any help will be appreciated

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,914

    Re: programmatically move child Form from parentMDI

    You should become familiar with the PointToScreen and PointToClient methods, that allow you to translate between a Point relative to a control (a form is a control) and a Point relative to the screen. For example, the following code will maintain the location of a child form relative to the screen when its MDI parent is maximised:
    vb.net Code:
    1. Dim position = Me.PointToScreen(mdiChildForm.Location)
    2.  
    3. Me.WindowState = FormWindowState.Maximized
    4. mdiChildForm.Location = Me.PointToClient(position)
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.