|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Resize nested control at runtimecotrol 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 Russ Green wrote:
Show quoteHide quote > I have a VB.NET app that uses lots of forms which I am loading into a panel <snip>> 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? 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. 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. Russ Green wrote:
> Thanks for the reply but I've now only got Maybe you need to provide more details, then (are you setting some of> > 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. those properties in the designer, for instance?). It resizes here... =) Regards, Branco.
Other interesting topics
GroupBox and/or Tab Control Font Colours
MDI app - don't load document twice toolstrip container backcolor and gradients - I want it to look like outlook 2003! OT: Crossword Puzzle Creator - .NET Source ClickOnce deployment, include font A Label control that its text can be selected with the mouse Need help on some PropertyGrid and PropertyGridView members Displaying a status image in a datagridview Setting a style for a selected row in the DataGridView Generating 3D graphs in .Net 2.0 windows forms. |
|||||||||||||||||||||||