C# 下利用代码创建按钮、定时器和标签
来源:互联网 发布:珍珠控台软件 编辑:程序博客网 时间:2024/05/29 08:53
一般在Form1.Designer.cs 文件下的InitializeComponent函数中进行
this.SuspendLayout();//公有,在窗体创建时自动创建
Timer控件
1 申明
privateSystem.Windows.Forms.TimerTimer_j;
2 实例化
this.components =newSystem.ComponentModel.Container();
this.Timer_j =newSystem.Windows.Forms.Timer(this.components);
3 设置
//
// Timer_j
//
this.Timer_j.Interval = 5000;//定时器初始化
this.Timer_j.Enabled =true;//定时器使能
this.Timer_j.Tick +=newSystem.EventHandler(this.Timer_j_Tick);//添加触发时间
Button控件
1 申明
privateSystem.Windows.Forms.Buttonbutton_start;
privateSystem.Windows.Forms.Buttonbutton_stop;
2 实例化
this.button_start =newSystem.Windows.Forms.Button();
this.button_stop =newSystem.Windows.Forms.Button();
3 设置
//
// button_start
//
this.button_start.Location =newSystem.Drawing.Point(200, 200);
this.button_start.Name ="button_start";
this.button_start.Size =newSystem.Drawing.Size(50, 20);
this.button_start.Text ="开始";
this.button_start.TabIndex = 1;
//
// button_stop
//
this.button_stop.Location =newSystem.Drawing.Point(400, 200);
this.button_stop.Name ="button_stop";
this.button_stop.Size =newSystem.Drawing.Size(50, 20);
this.button_stop.Text ="结束";
this.button_stop.TabIndex = 2;
4 加入窗口
this.Controls.Add(this.button_start);
this.Controls.Add(this.button_stop);
Label控件
1 申明
privateSystem.Windows.Forms.Labellabel_dis;
2 实例化
this.label_dis =newSystem.Windows.Forms.Label();
3 设置
//
// label_dis
//
this.label_dis.Location =newSystem.Drawing.Point(200, 100);
this.label_dis.Name ="label_dis";
this.label_dis.AutoSize =true;//自动调节大小
this.label_dis.Text ="ljj";
this.label_dis.TabIndex = 4;
4 加入窗口
this.Controls.Add(this.label_dis);
0 0
- C# 下利用代码创建按钮、定时器和标签
- C# 按钮和标签
- 155,纯代码创建标签和按钮,并关联点击事件
- 使用XAML和C#创建按钮
- Unity3D中创建按钮的实例代码(C#代码)
- VC代码创建按钮和图标控件
- C#定时器移动Label标签
- Java swing创建按钮和标签及处理
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 如何利用C#创建和调用DLL
- 利用C#创建DLL和调用DLL
- CI的CSRF防范原理及注意事项
- mr配置es
- 大型网站架构演化(三)——使用缓存改善网站性能
- ubuntu安装composer
- Web开发之JS事件
- C# 下利用代码创建按钮、定时器和标签
- iframe中的modal动态为页面添加元素后页面无法滚动
- git版本库创建三部曲(git权威指南笔记)
- 计算字符串中某一个字符的个数
- SpringMVC 对多视图的支持
- H.264编码原理I/B/P帧
- CalendarListview中自定义属性的翻译
- kruskal-边的贪心(并查集优化)-3
- RelativeLayout或FrameLayout点击事件穿透