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)文章
Ruby創(chuàng)建數(shù)組方法總結(jié)
在本篇文章里小編給大家分享了關(guān)于Ruby創(chuàng)建數(shù)組方法的知識點內(nèi)容,對戲有興趣的朋友們學習下。2019-01-01C#在foreach遍歷刪除集合中元素的三種實現(xiàn)方法
這篇文章主要給大家總結(jié)介紹了關(guān)于C#在foreach遍歷刪除集合中元素的實現(xiàn)方法,文中通過示例代碼介紹的非常詳細,對大家學習或者使用C#具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧2019-12-12C#中decimal保留2位有效小數(shù)的實現(xiàn)方法
這篇文章主要介紹了C#中decimal保留2位有效小數(shù)的實現(xiàn)方法,針對decimal變量保留2位有效小數(shù)有多種方法,可以使用Math.Round方法以及ToString先轉(zhuǎn)換為字符串等操作來實現(xiàn)。具體實現(xiàn)方法感興趣的朋友跟隨小編一起看看吧2019-10-10IIS下調(diào)用證書出現(xiàn)異常的解決方法 (C#)
這篇文章主要為大家詳細介紹了IIS下調(diào)用證書出現(xiàn)異常的解決方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-05-05