Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mimicking an Anchor or Dock property with Form object 1

Status
Not open for further replies.

JFoushee

Programmer
Oct 23, 2000
200
0
0
US
Hi. I've got in-line forms instantiated within docked tabpage controls.
What is the easiest way to get the in-line forms to resize with the main app?
I'd like to avoid the form's "resize" event, as the math never seems to add up.
___________________________

Example scenario:

Create a New Windows app

Add a Form "Form1":
Add a TabControl
Set TabControl1.Dock = Fill

Add a Form "Form2":
Set FormBorderStyle = None
Set BackColor = Maroon

Code inside Form1
Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim myForm2 As New Form2
        myForm2.TopLevel = False
        TabPage1.Controls.Add(myForm2)
        myForm2.Show()
    End Sub

I want the maroon control to resize with the main app.
 

Windows forms have the Anchor and Dock properties already, no need to "mimic" them.

Just do this:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myForm2 As New Form2
myForm2.TopLevel = False
[red]myForm2.Dock = DockStyle.Fill[/red]
TabPage1.Controls.Add(myForm2)
myForm2.Show()
End Sub

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
(Explitive)! I didn't think to review Intellisense for this... All I was going on was Solution Explorer properties, and assumed no Dock property was available.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top