Two easy tasks, that I have problem with.

muax

Newcomer
Joined
May 25, 2005
Messages
2
I am newbie in vb.net. Below situations may look very easy, but I have real trouble with it.

1) I have tryed almost everything (shared functions, inherits) but I couldnt solve this:

twoforms.jpg


2) I very need this second task to my project, but I even don't know if this is possible to do:

twoforms2a.jpg


..I need to create a function, that moves child form next to the main form and anchor it permanently..

twoforms2b.jpg


If anyone could solve this, thanks from above
 
Piece of cake:

Code:
    Private _frm As New Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        _frm.Show()
        _frm.Location = New Point(Me.Left + Me.Width, Me.Top)

    End Sub

    Private Sub Form1_Move(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Move
        _frm.Location = New Point(Me.Left + Me.Width, Me.Top)
    End Sub
Note: this only keeps the 2nd form docked if you move the first form. If you need it to snap back to the first form when you move the 2nd, pass a reference to the first form in the constructor:

Dim _frm As New Form2(Me)

Keep the reference as a member of Form2 (call it _frm). In the Form2 Move event just do:

Me.Location = New Point(_frm.Left + _frm.Width, _frm.Top)
 
Back
Top