将日期传递给按钮事件 [英] Passing the date to a button event

查看:68
本文介绍了将日期传递给按钮事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我想将日期传递给按钮事件。以下全部在一个按钮事件中完成。

Hi
I want to pass the date to a buttons event. the following is all done in one button event.

MonthCalendar calfront = new MonthCalendar();
           Form frmDate = new Form();
           Button btnDateUpdate = new Button();

           btnDateUpdate.Text = "Updates";
           btnDateUpdate.Dock = DockStyle.Bottom;


           frmDate.Width = 207;
           frmDate.Height = 210;
           frmDate.StartPosition = FormStartPosition.CenterScreen;

           frmDate.Controls.Add(btnDateUpdate);
           frmDate.Controls.Add(calfront);
           frmDate.Show();


           DateTime dateselected = calfront.SelectionEnd;
           MessageBox.Show(dateselected.ToString());





因此对于我添加的按钮,我需要一个可以将所选日期传递给的事件。



so for the button I added I need an event that i can pass the selected date to.

推荐答案





在Windows应用程序中,所有控件都将包含它的值。因此,在您的情况下,您可以直接从控件中获取所选日期值。



如果您遇到任何问题以获取所选日期的价值,请告知我们。它类似于从文本框中获取文本。



祝你好运。
Hi,

In windows application all control will contain it''s value. So in your case you can directly get the selected date value form the control.

Let us know if you face any issue to get the value of the selected date. it is similar like getting text from the textbox.

Best luck.


btnDateUpdate.Click += new EventHandler(btnDateUpdate_Click);



然后添加活动


then add the event

private void btnDateUpdate_Click(object sender, EventArgs e)
      {
          dateselected = calfront.SelectionEnd;
          string strSql = "Update this table Set dtmDateFileCreated = " + dateselected.ToString() + " where strGeneratedNumber = " + txtNewGenNumber.Text + "";
          objHost2Host.RunSql(strSql);
          frmDate.Close();

      }


这篇关于将日期传递给按钮事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆