控制台写始终程序,想在form鼠标点击处现实当前时间,时间倒是不用是动态的。
我只会用messagebox.show,弹出窗口显示,请问怎么能把messagebox.show改成在form里显示?
 public Event()
        {
            this.Click += new EventHandler(ClickReceive);
        }
        private void ClickReceive(object sender, EventArgs e)
        {
            MessageBox.Show(DateTime.Now.ToString());
        }

解决方案 »

  1.   

    在Form上放一个Label或者textBox,比如Label1,textBox1,Label1.Text=DateTime.Now.ToString();
    textBox1.Text=DateTime.Now.ToString();就可以显示,
      

  2.   

      private void ClickReceive(object sender, EventArgs e)
       {
       textBox1.Text=DateTime.Now.ToString();
       }
      

  3.   


    在Form的编辑界面上,从工具箱里拖一个Label到form中,如果你喜欢的话,也可以在Form的Load事件中自己new一个Label,
      

  4.   


    class Program
        {
            static System.Windows.Forms.Label lab;
            [STAThread]
            static void Main(string[] args)
            {
                
                System.Windows.Forms.Form test = new System.Windows.Forms.Form();
                lab = new System.Windows.Forms.Label();
                System.Timers.Timer tim = new System.Timers.Timer();
                tim.Elapsed += new System.Timers.ElapsedEventHandler(tim_Elapsed);
                test.Controls.Add(lab);
                test.Show();
            }        static void tim_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                lab.Text = DateTime.Now.ToString();
                       }
        }
      

  5.   

    我靠.忘启动了.记得加上tim.Start();