private void Form1_MouseLeave(object sender, EventArgs e)
{
                           (鼠标离开窗体 1秒)
this.Opacity=.50;

}
请教大仙 如何写在鼠标离开窗体一秒后,发生Opacity事件

解决方案 »

  1.   

    function clock() 
    {
    //本函数需要在<body  MS_POSITIONING="GridLayout">中加入onload="clock()"
    var timeStr;   
    now = new Date();
    var years = now.getFullYear();//年
    var months = now.getMonth()+1;//月
    var days = now.getDate();
    var hours=now.getHours();   
    var minutes=now.getMinutes();   
    var seconds=now.getSeconds();   
    timeStr="现在时刻: "+years+" 年"+months+" 月"+days+" 日  "+hours+" 时"+minutes+" 分"+seconds+" 秒"; 
    clock1.innerHTML=timeStr;//其中clock1是页面中div的控件的ID
    window.setTimeout("clock()",1000);   
    }
      

  2.   

    using System.Threading;
    namespace 定时器
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }
    int i;
    System.Threading.Timer timer1;
    public delegate void del_text(TextBox tb);
    public void aa(object ab)
    {
    i++;
    Invoke(new del_text(display), new object[] {textBox1});
    }
    public void display(TextBox tex)
    {
    textBox1 = tex;
    tex.Text = i.ToString();
    }
    private void button1_Click(object sender, EventArgs e)
    {
    //使用定时器的委托,用来代理在定时器重要执行的方法,此方法需要有一个object类型的形参
    TimerCallback del = new TimerCallback(aa);
    //初始化定时器,重载参数按提示的走
    timer1 = new System.Threading.Timer(del, null, 0, 1000);
    }