c#将datagridview日期显示放在日期时间选择器中
本文关键字:日期 时间 选择器 显示 datagridview | 更新日期: 2023-09-27 18:11:45
private void dgw_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
DataGridViewRow dr = dgw.SelectedRows[0];
TextBox1.Text = dr.Cells[0].Value.ToString();
cmdproduct.Text = dr.Cells[1].Value.ToString();
txtqty.Text = dr.Cells[2].Value.ToString();
txtrate.Text = dr.Cells[3].Value.ToString();
//txtstockdate.Text = dr.Cells[4].Value.ToString();
// txtstockdate.Value = Convert.ToDateTime(dr.Cells[4].Value.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
DateTime stockDate;
if (DateTime.TryParse(dr.Cells[4].Value.ToString(), out stockDate))
{
dateTimePicker1.Value = stockDate;
}