C#動態(tài)創(chuàng)建button按鈕的方法實例詳解
更新時間:2017年06月06日 10:34:40 投稿:lqh
這篇文章主要介紹了C#動態(tài)創(chuàng)建button按鈕的方法實例詳解的相關(guān)資料,需要的朋友可以參考下
C#動態(tài)創(chuàng)建button按鈕的方法實例詳解
C#編程中經(jīng)常需要動態(tài)創(chuàng)建,本文主要介紹C#動態(tài)創(chuàng)建button按鈕的方法,涉及C#按鈕屬性動態(tài)設(shè)置的相關(guān)技巧,以供借鑒參考。具體實現(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事件");
}
}
}
//注意:主要是看事件
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
C# SqlSugar批量執(zhí)行SQL語句及批量更新實體對象的操作方法
SqlSugar 是一款 老牌 .NET開源ORM框架,由果糖大數(shù)據(jù)科技團隊維護和更新 ,開箱即用最易上手的ORM,這篇文章主要介紹了C# SqlSugar批量執(zhí)行SQL語句以及批量更新實體對象,需要的朋友可以參考下2024-07-07
C# 延遲Task.Delay()和Thread.Sleep()的具體使用
Thread.Sleep()是同步延遲,Task.Delay()是異步延遲,本文主要介紹了C# 延遲Task.Delay()和Thread.Sleep()的具體使用,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-01-01
C#中緩存System.Web.Caching用法總結(jié)
本文詳細講解了C#中緩存System.Web.Caching的用法,文中通過示例代碼介紹的非常詳細。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2022-04-04

