ClassNew Obj1 = new ClassNew();
NewClass1 Obj2 = new NewClass1();
NewClass2 Obj3 = new NewClass2();
ArrayObject[i] = new ClassNew()
GridObject.SelectedObject = NewObject1;
setObjectClass(NewObject1, btnTemp.Text);
class NewClassProgram
{
public string NameOject = "#1";
button1.Text = NewObject1.NameOject;
private void button1_Click(object sender, EventArgs e)
{
GridObject.SelectedObject = NewObject1;
}
private void button2_Click(object sender, EventArgs e)
{
GridObject.SelectedObject = NewObject2;
NewObject2.SetMetClass2(NewObject1.GetMetdClass1());
}
private void button3_Click(object sender, EventArgs e)
{
GridObject.SelectedObject = NewObject3;
NewObject3.SetMetClass3(NewObject1.GetMetdClass1(), NewObject2.GetMetdClass2());
}
//Извлекаем кнопку
Button btn = (Button)e.Data.GetData(typeof(Button));
Panel pan = sender as Panel;
//Создание новой кнопки
int x1 = 3;
int y1 = 20;
p.X = x1;
p.Y = y1;
s2.Width = 201;
s2.Height = 87;
Button NewButtt = new Button();
NewButtt.Parent = this;
NewButtt.Location = p;
NewButtt.Size = s2;
NewButtt.Name = "button1";
NewButtt.Text = NewObject1.ToString();
NewButtt.BringToFront();
NewButtt.FlatStyle = FlatStyle.Flat;
//получаем клиентские координаты в момент отпускания кнопки
Point pointDrop = pan.PointToClient(new Point(e.X, e.Y));
//извлекаем клиентские координаты мыши в момент начала перетскивания
Point pointDrag = (Point)btn.Tag;
//вычисляем и устанавливаем Location для кнопки в Panel
pointDrop.Offset(-pointDrag.X, -pointDrag.Y);
btn.Location = pointDrop;
btn.Parent = pan;