除了从SQL Server执行此操作以外,还有其他方法可以做到吗?
我早些时候尝试了[NotMapped],但是它没有按预期工作。
下面的代码是我使Birthdate列成为DateTimePicker的工作。
选择日期后,我应该怎么做才能计算出年龄?
private void dataGridViewFamMems_CellClick(object sender, DataGridViewCellEventArgs e)
{
switch(dataGridViewFamMems.Columns[e.ColumnIndex].Name)
{
case "birthdateFam":
_Rectangle = dataGridViewFamMems.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
dtp.Size = new Size(_Rectangle.Width, _Rectangle.Height);
dtp.Location = new Point(_Rectangle.X, _Rectangle.Y);
dtp.Visible = true;
break;
}
}
private void dtp_TextChange(object sender, EventArgs e)
{
dataGridViewFamMems.CurrentCell.Value = dtp.Text.ToString();
}
private void dataGridViewFamMems_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
{
dtp.Visible = false;
}
private void dataGridViewFamMems_Scroll(object sender, ScrollEventArgs e)
{
dtp.Visible = false;
}
}