C#動態(tài)創(chuàng)建button的方法
更新時間:2015年08月27日 12:29:36 作者:我心依舊
這篇文章主要介紹了C#動態(tài)創(chuàng)建button的方法,涉及C#按鈕屬性動態(tài)設(shè)置的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了C#動態(tài)創(chuàng)建button的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
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 System.Reflection;
namespace App
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
System.Windows.Forms.Button button = new Button();
button.Text = "按鈕";
button.Size = new Size(100, 30);
button.Location = new Point(0, 0);
button.Click += delegate { ButtonClick(); };
this.Controls.Add(button);
}
void ButtonClick()
{
MessageBox.Show("點擊了click事件");
}
}
}
//注意:主要是看事件
希望本文所述對大家的C#程序設(shè)計有所幫助。
相關(guān)文章
C#數(shù)據(jù)結(jié)構(gòu)之雙向鏈表(DbLinkList)實例詳解
這篇文章主要介紹了C#數(shù)據(jù)結(jié)構(gòu)之雙向鏈表(DbLinkList),結(jié)合實例形式較為詳細的講解了雙向鏈表的概念及C#實現(xiàn)雙向鏈表的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11
c#方法中調(diào)用參數(shù)的值傳遞方式和引用傳遞方式以及ref與out的區(qū)別深入解析
以下是對c#方法中調(diào)用參數(shù)的值傳遞方式和引用傳遞方式,以及ref與out的區(qū)進行了詳細的分析介紹,需要的朋友可以過來參考下2013-07-07

