Visual C# 2010学习笔记一之命令控件的使用
来源:互联网 发布:c语言在线测试网站 编辑:程序博客网 时间:2024/06/05 04:57
今年七月份刚大学毕业,属于技术小白,出来工作还算安逸,每月的大洋还是能够解决个人温饱的,但考虑到以后的发展,必须掌握一技之长,方可更好的生存。所以想在工作之余学习一下C#和一些数据库类的知识。并同步做学习笔记,以便温故。
今天学习掌握了3个命令控件,分别为:Button,LinkLabel,NotifyIcon。
Button:windows窗体的Button控件允许用户通过单击来执行操作。
LinkLabel:winodows窗体的LinkLabel控件使你可以向Windows窗体应用程序中添加web样式的链接。
NotifyIcon:Windows窗体的NotifyIcon组件通常用于显示在后台运行的进程的图标。
今天参考书本,做了一个窗体应用程序,如图:
第一步:创建Windows窗体应用程序项目,在Form1上分别添加Button,LinkLabel,NotifyIcon控件,并完成简单布局。
第二步:单击Button,在属性窗口对Text的属性进行命名修改,其他的Button同理。
第三步:单击添加的LinkLabel,在属性窗口将Text属性设置为“欢迎访问NFCP”,将LinkArea属性设置为“4,4”(因为缩写NFCP,在左起第4个字后,且长度为4),将NotifyIconTipIcon属性设置为Info(将在系统任务栏里显示图标),BallonTipText设置为“双击下面的图标打开程序主窗口”(气泡提醒的内容),BallonTipTittle设置为“温馨提示”(气泡提醒的标题),Icon设置为一个图标文件(ico文件可以网上下载或者用软件自制),Text设置为“应用示例正在运行”(此处也可自定义图标的名称)。
第四步:在代码编辑器中打开源文件Form1.cs然后编写事件的处理程序,我的处理程序如下:
namespace 小工具练习
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide(); //隐藏窗口
this.notifyIcon1.Visible = true; //判断是否显示在后台运行进程的图标
this.notifyIcon1.ShowBalloonTip(6000); //设置气泡提示,指定6秒后关闭
System.Diagnostics.Process.Start("http://www.fujitsu-nfcp.com/"); //调用外部程序
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://fushitong.jd.com/");
}
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://shop.suning.com/30000152/index.html");
}
private void button4_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://qjbgyp.tmall.com/");
}
private void button5_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://www.dayinjiqudong.com");
}
private void button6_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://www.fujitsu-nfcp.com/product/haocai/");
}
private void button7_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://www.fujitsu-nfcp.com/service/");
}
private void button8_Click(object sender, EventArgs e)
{
this.Hide();
this.notifyIcon1.Visible = true;
this.notifyIcon1.ShowBalloonTip(6000);
System.Diagnostics.Process.Start("http://www.fujitsu-nfcp.com/plus/list.php?tid=11");
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
try
{
VisitLink();
}
catch (Exception)
{
MessageBox.Show("Unable to open link that was clicked");
}
}
private void VisitLink()
{
linkLabel1.LinkVisited = true;
System.Diagnostics.Process.Start("http://www.fujitsu-nfcp.com/");
}
}
}
第五步:点击保存,按F6调试,按F5运行。
第六步:如果你运行后的窗口不居中,可以单击Form1窗体,将CenterScreen设置为CenterScreen即可。
运行后点击按钮窗体会隐藏,并且打开相应链接,任务栏的图标如下:
小白笔记,如有错误,谢谢指出!
- Visual C# 2010学习笔记一之命令控件的使用
- Visual C# 2010学习笔记二之设置选项控件的使用
- Visual C#2010学习笔记四之列表选择控件的使用
- Visual C#2010学习笔记三之return返回值的使用
- Visual C#2010学习笔记五之变量和常量的使用
- Visual C#2010学习笔记七之for语句的使用
- Visual C#2010学习笔记八之out和ref的使用
- C#中使用Property Grid 控件 学习笔记(一)
- C#中使用Property Grid 控件 学习笔记(一)
- Visual Studio 2010——C#工具栏控件的使用
- Visual Studio 2010——C#状态栏控件的使用
- Visual Studio 2010—— C#的ComboBox控件使用
- c#学习笔记之使用 TableLayoutPanel 控件设置窗体布局
- Visual C#2010学习笔记六之运算符的重载
- Visual C#2010学习笔记九之.dll类库文件的引用
- C#学习笔记-WPF前端布局和控件的使用
- C#学习笔记__文本编辑、列表控件的使用示例
- C#学习笔记__容器控件的使用
- 【分块】UVA 12003 Array Transformer 水题
- 能力天空视频下载助手
- C#实现 Linq 序列的Distinct—— IEnumerable<T>.Distinct<T>()——IEqualityComparer
- HOJ 13348 Finding Lines 画直线最多点
- C#文件流的操作
- Visual C# 2010学习笔记一之命令控件的使用
- 对面向接口编程的理解
- 【练习题】27.2-35进制数转换为10进制数
- [leetcode-63]Unique Paths II(c)
- 在转换为 UTC 时大于 DateTime.MaxValue 或小于 DateTime.MinValue 的 DateTime 值无法系列化为 JSON
- centOS安装qt4.8.0 - - ERROR: Package gstreamer-app-0.10 not found
- ffmpeg+ffserver搭建流媒体服务器
- SGU134 Centroid 树形DP基础题,求树的重心
- android将LinearLayout中的内容保存为Bitmap。