Bonjour,

Est-ce que quelqu'un sait comment docker un contrôle dans un FlowLayoutPanel ?

Malgré mes recherches et tests, je ne parviens pas à docker (TOP) un bouton dans un FlowLayoutPanel qui est lui-même docker (FILL).

Ci-dessous, un bout de code définissant le problème ?

Merci par avance de votre aide.

Cordialement,

Sylum

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
public partial class Form1 : Form
{
    public Form1()
    {
        CreateMyFlowLayoutPanel();
    }
 
    public void CreateMyFlowLayoutPanel()
    {
        FlowLayoutPanel flpPanel = new FlowLayoutPanel();
        Button button1 = new Button();
 
        // Set the Borderstyle for the FlowLayoutPanel to three-dimensional.
        flpPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
 
        // Initialize the button control.
        button1.Text = "button1";
        button1.Size = new Size(150, 25);
 
        // Dock FlowLayoutPanel control to form control.
        flpPanel.Dock = DockStyle.Fill;
        // Dock button1 control control to FlowLayoutPanel control.
        button1.Dock = DockStyle.Top;
 
        // Add the Panel control to the form.
        this.Controls.Add(flpPanel);
 
        // Add the Button control to the Panel.
        flpPanel.Controls.Add(button1);
    }
 
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
    }
}