How to insert the upper docking controls under the preview of the upper docked controls on the panel

I use panel.controls.add to add controls to the panel. But ... they are inserted at the very top.

I tried the BringToFront and SendToBack methods, but it doesn't seem to work.

Any ideas? Thanks

EDIT:

what I want is that they dock at the top of the container, but if there is another docked control, a new one is displayed below this ...

+5
source share
4 answers

Controls. . . SetChildIndex(), 0:

        var btn = new Button();
        btn.Dock = DockStyle.Top;
        panel1.Controls.Add(btn);
        panel1.Controls.SetChildIndex(btn, 0);
+13

.

  • , , , .

    Example:
    Panel.Controls.Add(Label1)
    Panel.Controls.Add(Label2)
    Panel.Controls.Add(Label3)
    
  • , .

    Example
    Panel.Controls.Add(Label3)
    Panel.Controls.Add(Label2)
    Panel.Controls.Add(Label1)
    

, , ( ), ( ).

+2

", , , , , ..."

, . :

  • Anchor ( Top) Dock - , , ( Width, ). , 2:

  • - TableLayoutPanel - , TableLayoutPanel. Columns, eachother. ( - .)

+1

:

Open the form in the Design view. Open the "Document Structure" - "View" | Other windows | The structure of the document is ( Ctrl+ Alt+ T).

The document structure displays the layout panels in a tree view in the reverse order that they appear on the form. In the "Document Structure" window, you can change the order of the panels. Due to the reverse order, everything shown at the top of the document will be at the bottom of the form.

0
source

All Articles