private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
try
{
if ((dataGridView1.Focused) && (dataGridView1.CurrentCell.ColumnIndex == 0))
{
dtpInstallment.Location = dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, false).Location;
dtpInstallment.Visible = true;
if (dataGridView1.CurrentCell.Value != DBNull.Value)
{
// dtpInstallment.Value = DateTime.Today;
dtpInstallment.Value = (DateTime)dataGridView1.CurrentCell.Value;
// DateTime date = (DateTime)dataGridView1.CurrentCell.Value;
// dtpInstallment.Value = DateTime.Parse(date.ToString("dd/MM/yyyy"));
}
else
{
dtpInstallment.Value = DateTime.Today;
}
}
else
{
dtpInstallment.Visible = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
在這個日期被拋出異常......存在dataGridView1.CurrentCell.Value..but值無法轉換爲dtpInstallment.value這是DateTimePicker日期時間在C#中引發異常指定的轉換是無效
裏面是什麼'dataGridView1.CurrentCell.Value'? – Habib
它正在從datagridcell中取數據,它正在從數據庫中獲取數據的值... –