问题: 在弹出一个对话框时,窗口上有"确定", "取消"两个按钮,假设等待5秒后,还没有执行任何操作,怎样让程序自动执行"确定"按钮,就像安装操作系统时一样,用户没有设置时就按默认步骤进行安装?

解决方案 »

  1.   

    能说具体些吗?
    比如说点确定后执行自定义函数dataManager();怎样在过5秒后对话框关闭,然后执行dataManager();
      

  2.   

    Timer timer = this.statusTimer = new Timer(this.components);
    timer.Tick += new EventHandler(timer_Tick);
    timer.Interval = 5000;//5秒
    timer.Enabled = true;
    timer.Start();int count = 0;
    private void timer_Tick(object sender, System.EventArgs e)
    {
        if (count >= 1)
        {
            //确定
        }
        count++;
    }
      

  3.   

    //确定
    ----
    这里你可以执行dataManager();并且this.DialogResult = DialogResult.OK;//关闭窗口,如果要是show出来的话就用this.Close()
      

  4.   

    不好意思,上面写错了
    Timer timer = new Timer();
    timer.Tick += new EventHandler(timer_Tick);
    timer.Interval = 5000;//5秒
    timer.Enabled = true;
    timer.Start();private void timer_Tick(object sender, System.EventArgs e)
    {
        dataManager();
        this.DialogResult = DialogResult.OK;//如果是showdialog
        this.Close();//如果是show
    }
      

  5.   

    弹出的对话框如下:
    DialogResult msgResult = MessageBox.Show("要继续操作吗?", "操作提示", MessageBoxButtons.YesNo,MessageBoxIcon.Information);if (msgResult == DialogResult.Yes)
    {
         DataManager();
    }怎样实现过5秒后还没有点"是"按钮, 就执行DataManager();