// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Drawing; using System.Windows.Forms; namespace E { public class MainForm : Form { private Button button1; public MainForm() { InitializeComponent(); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } private void InitializeComponent() { button1 = new Button(); SuspendLayout(); button1.Location = new Point(100, 25); button1.Size = new Size(100, 25); button1.Text = "Tilføj"; button1.Click += new System.EventHandler(Button1Click); ClientSize = new Size(300, 300); Controls.Add(button1); Text = "Main Form"; ResumeLayout(false); } private int y = 50; void Button1Click(object sender, EventArgs e) { Label lbl = new Label(); lbl.Text = "Dynamisk tilføjet"; lbl.Location = new Point(100, y); lbl.Size = new Size(100, 15); y += 25; Controls.Add(lbl); } } }