如何将datetimepicker的值传递给另一种形式的另一个datetimepicker

时间:2017-06-16 20:51:38

标签: c# ms-access datagridview

我在datagridview中有一个datetimepicker值。 (抵达日期和出发日期) 这是屏幕截图。 Screenshot 1

另外,我在datagrid视图中有一个值的编辑表单。

enter image description here

如何将datetimepicker的值从datagridview传递给第二个表单作为datetimepicker值。

这是我的尝试:

  private void arrivaldgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            edit edt = new edit();
            edt.label12.Text = this.label2.Text;
            edt.label13.Text = this.arrivaldgv.CurrentRow.Cells[0].Value.ToString();
            edt.textBox1.Text = this.arrivaldgv.CurrentRow.Cells[1].Value.ToString();
            edt.textBox2.Text = this.arrivaldgv.CurrentRow.Cells[2].Value.ToString();
            edt.textBox3.Text = this.arrivaldgv.CurrentRow.Cells[3].Value.ToString();
         /*   edt.dateTimePicker1.Value = this.arrivaldgv.CurrentRow.Cells[4].Value;   problem here */
            edt.ShowDialog();
        }

2 个答案:

答案 0 :(得分:0)

尝试System.Convert.ToDateTime方法:

edt.dateTimePicker1.Value = System.Convert.ToDateTime(this.arrivaldgv.CurrentRow.Cells[4].Value);

答案 1 :(得分:0)

您可以使用ick el ic ik el 方法:

DateTime.Parse

大多数edt.dateTimePicker1.Value = DateTime.Parse(this.arrivaldgv.CurrentRow.Cells[4].Value); 方法在内部使用一些实例方法,这也是这种情况,这意味着它应该比.ToX

更快地工作