Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

Resize nested control at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Russ Green - 12 Feb 2007 11:14 GMT
I have a VB.NET app that uses lots of forms which I am loading into a panel
cotrol using.....

Me.pnlMain.Controls.Clear()

frm.TopLevel = False
frm.WindowState = FormWindowState.Maximized
frm.Dock = DockStyle.Fill
frm.Anchor = AnchorStyles.Left + AnchorStyles.Right + AnchorStyles.Top +
AnchorStyles.Bottom
frm.AutoSize = True
frm.AutoSizeMode = Windows.Forms.AutoSizeMode.GrowAndShrink

Me.pnlMain.Controls.Add(frm)
frm.Show()

What I want to do though is have the form resize when the panel control
(which resizes with it's main form) resizes....i've tried something like the
following but it's not working....How can I do this?

   Private Sub pnlMain_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles pnlMain.Resize
       On Error Resume Next
       Debug.WriteLine(Me.pnlMain.Size.Width.ToString & " x " &
Me.pnlMain.Size.Height.ToString)
       Debug.WriteLine(Me.pnlMain.Controls.Item(0).Width & " x " &
Me.pnlMain.Controls.Item(0).Height)

       Dim oFrm As New Form

       If Me.pnlMain.Controls.Count > 0 Then
           'Debug.WriteLine("There is a control in the panel " &
Me.pnlMain.Controls.Item(0).Name)
           With Me.pnlMain.Controls.Item(0)
               .Size = New Size(Me.pnlMain.Size.Width,
Me.pnlMain.Size.Height)
           End With

       End If
   End Sub
Branco Medeiros - 12 Feb 2007 13:30 GMT
> I have a VB.NET app that uses lots of forms which I am loading into a panel
> cotrol using.....
[quoted text clipped - 15 lines]
> (which resizes with it's main form) resizes....i've tried something like the
> following but it's not working....How can I do this?
<snip>

You're doing too much. You only need to set TopLevel to false, Dock to
Fill and add the form to the panel. The other properties (WindowState,
Autosize, etc) are not needed. Setting WindowState will actually
prevent the form from automatically resizing.

HTH.

Regards,

Branco.
Russ Green - 12 Feb 2007 13:40 GMT
Thanks for the reply but I've now only got

       Me.pnlMain.Controls.Clear()

       frm.TopLevel = False
       frm.Dock = DockStyle.Fill

       Me.pnlMain.Controls.Add(frm)
       frm.Show()

And when my panel resizes the form I've loaded into it doesn't.
Branco Medeiros - 12 Feb 2007 14:20 GMT
> Thanks for the reply but I've now only got
>
[quoted text clipped - 7 lines]
>
> And when my panel resizes the form I've loaded into it doesn't.

Maybe you need to provide more details, then (are you setting some of
those properties in the designer, for instance?).

It resizes here... =)

Regards,

Branco.
Russ Green - 12 Feb 2007 14:50 GMT
Yes,   some of the other properties are set in the designer....found them
and fixed it.....troubled me for ages....thanks

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.