نوشته شده توسط
voice.of.silence
سلام دوستان:
با فراخوانی یک کلاس کنترل می توان به صورت داینامیک به فرم کنترل مربوطه را اضافه کرد اما نمی دانم که چگونه برایش کد بنویسم.
برای combobox و امثال آن می دانم که چه بنویسم اما برای چند button که اضافه شده اند نمی دانم چه بنویسم .
لطفا مرا راهنمایی نمایید.
با تشکر .
Voice of Silence
سلام
تفاوت خاصی ندارد.
//in the name of god
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
publicpartialclassForm1 : Form
{
System.Windows.Forms.Button button1 = new System.Windows.Forms.Button();
public Form1()
{
InitializeComponent();
this.button1.Click += new System.EventHandler(this.button1_Click);
this.Controls.Add(this.button1);
}
privatevoid button1_Click(object sender, EventArgs e)
{
System.Windows.Forms.MessageBox.Show("hello");
}
privatevoid Form1_Load(object sender, EventArgs e)
{
this.button1.Left = 100;
this.button1.Top = 100;
this.button1.Text = "ok";
}
}
}