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;
using ClassLibraryExample;
namespace FormExample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Class1.Create(50, 50);
}
}
}
//someX,someY,someWidth & someHeight have values set somewhere
public void AddButtonToForm(Form someForm)
{
Button b = new Button();
b.Text = "Do Something";
b.Location = new Point(someX,someY);
b.Size = new Size(someWidth,someHeight);
b.Click += new System.EventHandler(this.someButton_Click);
someForm.Controls.Add(b);
}
private void someButton_Click(object sender, EventArgs e)
{
//Do Something here
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Forms;
using System.Drawing;
namespace agUltimate2011
{
public class agNet
{
}
public class agSpecial
{
public void Windmill(Form formToAddWindmillTo, int x, int y)
{
Button button1 = new System.Windows.Forms.Button();
Button button2 = new System.Windows.Forms.Button();
Button button3 = new System.Windows.Forms.Button();
Button button4 = new System.Windows.Forms.Button();
button1.Location = new System.Drawing.Point(x, y);
button1.Name = "windmill1";
button1.Size = new System.Drawing.Size(75, 23);
button1.TabIndex = 0;
button1.Text = "Create New";
button1.UseVisualStyleBackColor = true;
button1.Click += new System.EventHandler(click1);
button2.Location = new System.Drawing.Point(x + 10 + button2.Width, y);
button2.Name = "windmill2";
button2.Size = new System.Drawing.Size(75, 23);
button2.TabIndex = 0;
button2.Text = "Create New";
button2.UseVisualStyleBackColor = true;
button2.Click += new System.EventHandler(click2);
button3.Location = new System.Drawing.Point(x + 10 + button2.Width, y + 10 + button2.Height);
button3.Name = "windmill3";
button3.Size = new System.Drawing.Size(75, 23);
button3.TabIndex = 0;
button3.Text = "Create New";
button3.UseVisualStyleBackColor = true;
button3.Click += new System.EventHandler(click3);
button4.Location = new System.Drawing.Point(x, y + 10 + button1.Height);
button4.Name = "windmill4";
button4.Size = new System.Drawing.Size(75, 23);
button4.TabIndex = 0;
button4.Text = "Create New";
button4.UseVisualStyleBackColor = true;
button4.Click += new System.EventHandler(click4);
formToAddWindmillTo.Controls.Add(button1);
formToAddWindmillTo.Controls.Add(button2);
formToAddWindmillTo.Controls.Add(button3);
formToAddWindmillTo.Controls.Add(button4);
}
private void click1(object sender, EventArgs e)
{
MessageBox.Show("You clicked Button 1");
}
private void click2(object sender, EventArgs e)
{
MessageBox.Show("You clicked Button 2");
}
private void click3(object sender, EventArgs e)
{
MessageBox.Show("You clicked Button 3");
}
private void click4(object sender, EventArgs e)
{
MessageBox.Show("You clicked Button 4");
}
}
}
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;
using agUltimate2011;
namespace TestForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
agSpecial agSpecial = new agSpecial();
agSpecial.Windmill(this, 20, 20);
}
}
}
