C#動態(tài)創(chuàng)建button按鈕的方法實例詳解
更新時間:2017年06月06日 10:34:40 投稿:lqh
這篇文章主要介紹了C#動態(tài)創(chuàng)建button按鈕的方法實例詳解的相關資料,需要的朋友可以參考下
C#動態(tài)創(chuàng)建button按鈕的方法實例詳解
C#編程中經(jīng)常需要動態(tài)創(chuàng)建,本文主要介紹C#動態(tài)創(chuàng)建button按鈕的方法,涉及C#按鈕屬性動態(tài)設置的相關技巧,以供借鑒參考。具體實現(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#使用Socket快速判斷數(shù)據(jù)庫連接是否正常的方法
這篇文章主要介紹了C#使用Socket快速判斷數(shù)據(jù)庫連接是否正常的方法,涉及C#中socket操作的相關技巧,非常具有實用價值,需要的朋友可以參考下2015-04-04
C#實現(xiàn)DataList里面嵌套DataList的折疊菜單
這篇文章主要介紹了C#實現(xiàn)DataList里面嵌套DataList的折疊菜單,以實例形式詳細分析了DataList嵌套實現(xiàn)折疊菜單所涉及的JavaScript、HTML與C#相關使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-11-11
Unity Shader實現(xiàn)圖形繪制(藍天白云大海)
這篇文章主要為大家詳細介紹了Unity Shader實現(xiàn)圖形繪制,藍天白云大海,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-04-04
C#對多個集合和數(shù)組的操作方法(合并,去重,判斷)
下面小編就為大家?guī)硪黄狢#對多個集合和數(shù)組的操作方法(合并,去重,判斷)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12

