Splitcontainer flowlayoutpanel or authorized panel (VB.NET)

The forms in the application I'm working on with the team have a data grid as their main component (it should occupy most of the size), but there are other components. there is a horizontal container for separation, but I was wondering how to make the top panel resize the content. Unfortunately, panels in a separate container do not have the property AutoSize...

Here are two images to show what we need: image1
(source: mediafire.com )

image2
(source: mediafire.com )

As you can see, the top panel of the split container should fit the size of its contents. Is there any way to achieve this?

+5
source share
1

, "" .

, ControlAdded :

Public Class Form1

  Public Sub New()
    InitializeComponent()
  End Sub

  Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
    SplitContainer1.SplitterDistance = SmallPanel.Height
  End Sub

  Private Sub SplitContainer1_Panel1_ControlAdded(ByVal sender As Object, ByVal e As ControlEventArgs) Handles SplitContainer1.Panel1.ControlAdded
    SplitContainer1.SplitterDistance += e.Control.Height
  End Sub

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim addPanel As New Panel
    addPanel.BorderStyle = BorderStyle.FixedSingle
    addPanel.Size = New Size(SplitContainer1.Panel1.ClientSize.Width, 100)
    addPanel.Location = New Point(0, SplitContainer1.SplitterDistance)
    addPanel.Anchor = AnchorStyles.Left Or AnchorStyles.Top Or AnchorStyles.Right
    SplitContainer1.Panel1.Controls.Add(addPanel)
  End Sub

End Class

SmallPanel - , Panel1 SplitContainer, .

+3

All Articles