All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
delphi程序中动态创建、删除视图
GDI+绘制验证码图片
c#中GDI+图形图像:GDI+中的画笔使用方法
使用IConfigurationSectionHandler在web.config中增加自定义配置_[Asp.Net教程]
javascript,函数,检查图片大小是否大于预期大小_JavaScript技术_编程技术
谈谈新手如何学习PHP_php资料_编程技术
加快Sql server时间查询速度的办法_[SQL Server教程]
ASP生成WML文件源代码样本_[XML教程]
Zope的优点和Apache+PHP+MySQL的比较_[PHP教程]
SQLServer实现工具的中英文界面互换_[SQL,Server教程]
Reading number is top 10 pictures
南昌铁路局攸县车站125户铁路职工微利房终成骗局
不知名的美女素颜照1
Female model behind the bitterness, often being overcharged5
Sora aoi on twitter5
The money of more than 100 countries and regions17
29 the belle stars after bath figure4
Japan sexy beauty passion photo
Sora aoi after swimming
美女当网吧管理员的悲剧
The goddess of the single reason1
Download software ranking
超级战舰
Dance with duck(male prostitution)
传奇私服架设教程
dreamweaver8中文版
Tram sex maniac 2 (H) rar bag6
asp.net技术内幕
Tram sex maniac 2 (H) rar bag15
apache-tomcat-6.0.33
网络管理员第三版
The Bermuda triangle2
qq published in(发表于) 2014/7/11 9:17:11 Edit(编辑)
C#中Label控件应用实例

C#中Label控件应用实例

C#中Label控件应用实例

Label控件

1.功能

Label控件即标签控件,是Windows应用程序中最基本的控件。Label控件用来显示用户不能直接改变的文本信息。可以在“属性”窗口中设置控件的文本信息,也可以通过编写代码来设置要显示的文本信息。在向窗体添加Label控件时,系统会自动创建Label控件的一个对象。图1为Label控件。

向窗体添加Label控件的步骤如下。

(1)在“工具箱”窗口中选择要添加的Label控件。

(2)将鼠标焦点移动到窗体上,当鼠标指针变为十字形时,按住鼠标左键同时拖曳鼠标,当达到所需要的大小时释放鼠标,此时控件将被添加到窗体中,如图2所示。其他控件的添加方法与Label控件类似,不再详细介绍。



图1 Label控件



图2 在窗体中添加控件

2.属性

Label控件常用属性及说明如表1所示。

表1 Label控件常用属性及说明



续表



下面对比较重要的属性进行详细介绍。

(1)Text属性。用来设置要在该控件上显示的文本。

语法:

public override string Text { get; set; }
示例

使用Text属性设置控件的显示文本

本示例实现的功能是,当程序运行时,在Label控件中显示“欢迎你”文本信息。

程序主要代码如下:

private void frmLabel_Load(object sender, EventArgs e)

{

this.label1.Text = "欢迎你";

}

(2)Visible属性。用于设置控件是否可见。

语法:

public bool Visible { get; set; }
属性值:如果显示该控件,则为True,否则为False。一般默认为True。

例如,下面用来设置Label2控件是可见的,代码如下:

label2.Visible = True;
完整程序代码如下:

★★★★★主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace _8_01

{

static class Program

{

///



/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new frmLabel());

}

}

}

★★★★★frmLabel窗体设计文件完整程序代码★★★★★


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.