如何将DATETIME值传输到另一个表单。 [英] How to transfer DATETIME value to another form.

查看:93
本文介绍了如何将DATETIME值传输到另一个表单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表单,在form1上,我有一个maskedtextbox来键入我的DATETIME值,我想把我的日期时间值显示在我的表单2上


form1 i宣布 


 公共部门类Form1:表格

    {

       公共静态字符串日期



        public Form1()

        {

            InitializeComponent();

        }


我用于蒙面盒的计算我的程序的日期时间


  bool b = DateTime.TryParse(maskedTextBox1.Text,out DateTime tempDate);

                    int days = int.Parse(textBox1.Text);

                    DateTime日期= tempDate.AddDays(天);

                    maskedTextBox2.Text = date.ToString();



Form2我声明:


  maskedTextBox1.Text = Form1.date;



但我在masedtextbox1中为表单1输入的内容不在我的maskedtextbox1中我的表单2

解决方案

该链接可以帮助您。


http://net-informations.com/q/faq/passvalues.html


I have two forms, on form1, i have a maskedtextbox to key in my DATETIME value and i wan my datetime value to be shown on my form 2

form1 i declared 

 public partial class Form1 : Form
    {
        public static string date

        public Form1()
        {
            InitializeComponent();
        }

What i used for my maskedbox to calculate the datetime for my program

  bool b = DateTime.TryParse(maskedTextBox1.Text, out DateTime tempDate);
                    int days = int.Parse(textBox1.Text);
                    DateTime date = tempDate.AddDays(days);
                    maskedTextBox2.Text = date.ToString();

Form2 i declared:

 maskedTextBox1.Text = Form1.date;

But the input of what i entered in masedtextbox1 for my form 1 was not in my maskedtextbox1 my form 2

解决方案

The link should help you.

http://net-informations.com/q/faq/passvalues.html


这篇关于如何将DATETIME值传输到另一个表单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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