我在datagridview中有一个datetimepicker值。 (抵达日期和出发日期) 这是屏幕截图。
另外,我在datagrid视图中有一个值的编辑表单。
如何将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();
}
答案 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