实例008 浮动工具栏
操作步骤:
(1)新建 Windows应用程序窗体 项目,命名为 Ex01_08,默认窗体为 Form1。
(2)添加 Panel、timer 和 textBox 控件。
(3)在 Panel 上添加两个 Label 控件,设置Text 属性为 打开 和 关闭,设置 BackColor 属性为 Transparent。
(4)选择 timer 控件,设置 Enabled 属性为 True,设置 Interval 属性为 1000。
完整代码:
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;
namespace Ex01_08
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.textBox1.Focused == false)
{
this.Top = -40;
}
}
private void label2_Click(object sender, EventArgs e)
{
this.Close();
}
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
Focus();
this.Top = 60;
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
Focus();
this.Top = 60;
}
}
}

没有评论:
发表评论