首页 > 代码库 > 自定义 控件

自定义 控件

1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Drawing; 5 using System.Data; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms;10 11 namespace WindowsFormsApplication112 {13     public partial class TestControl : UserControl14     {15         private string UserName="";16         public TestControl()17         {18             InitializeComponent();19         }20         public TestControl(string uid)21         {22             InitializeComponent();23             UserName = uid;24         }25 26         private void TestControl_Load(object sender, EventArgs e)27         {28             YongHuDA da = new YongHuDA();29             YongHu data = http://www.mamicode.com/da.Select(UserName);"label1"].Text = label1.Text;44 45         }46 47         private void button1_Click(object sender, EventArgs e)48         {49 50         }51 52        53 54 55 56     }57 }

技术分享

 1 using System; 2 using System.Collections.Generic; 3 using System.ComponentModel; 4 using System.Data; 5 using System.Drawing; 6 using System.Linq; 7 using System.Text; 8 using System.Threading.Tasks; 9 using System.Windows.Forms;10 11 namespace WindowsFormsApplication112 {13     public partial class Form1 : Form14     {15         public Form1()16         {17             InitializeComponent();18         }19 20         private void Form1_Load(object sender, EventArgs e)21         {22             YongHuDA da = new YongHuDA();23             List<YongHu> list = da.Select();24 25             foreach (YongHu data in list)26             {27                 TestControl ctrl = new TestControl(data.Uid);28                 flowLayoutPanel1.Controls.Add(ctrl);29             }30         }31     }32 }

自定义 控件