Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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:

 

http://www.wsms.webpark.pl/twoforms.jpg

 

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

 

http://www.wsms.webpark.pl/twoforms2a.jpg

 

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

 

http://www.wsms.webpark.pl/twoforms2b.jpg

 

If anyone could solve this, thanks from above

Posted

Piece of cake:

 


   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)

Here's what I'm up to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...