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 48 49 50 51 52 53 54 55 56
|
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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private UserControl1 myControl;
private Button myButton;
private TextBox myTextBox;
public Form1()
{
InitializeComponent();
//big usercontrol
myControl = new UserControl1();
myControl.Location = new Point(100, 100);
myControl.Size = new Size(500, 500);
// button dans le panel à droite du UserControl
myButton = new Button();
myButton.Location = new Point(myControl.Right+50, 100);
myButton.AutoSize = true;
myButton.Text = "Button1";
// textbox dans le panel en dessous du UserControl
myTextBox = new TextBox();
myTextBox.Location = new Point(100, myControl.Bottom + 40);
myTextBox.Size = new Size(400, 40);
myTextBox.ScrollBars = ScrollBars.Both;
myTextBox.Font = new Font("arial", 16, FontStyle.Bold);
myTextBox.Text = "les scroolbars n'apparaissent que si taille contenu > taille panel ...";
myTextBox.Multiline = true;
//minus panel
this.panel1.Size = new Size(200, 200);
this.panel1.AutoScroll = true;
this.panel1.Dock = DockStyle.Fill;
this.panel1.Controls.Add(myControl);
this.panel1.Controls.Add(myButton);
this.panel1.Controls.Add(myTextBox);
//size du form limite:le panel aura la meme taille que le form a cause du DockStyle.Fill
//et la condition 2 va s'appliquer au panel et donc au form
this.MaximumSize = new Size(400, 400);
}
}
} |
Partager