DataGridView CalendarColumn があります。デフォルトでは、データベース テーブルにバインドされている列が NULL の場合、現在の値が表示されますが、それも NULL にする必要があります。
たとえば、その特定の日付列のデータの場合、ユーザーが日付セルを空(NULL)にできるようにしたいのですが、これを実現するために設定するプロパティが見つかりません。DatagridviewのCalendercolumnでこの種の動作を実現することは、どんなアイデアでも可能です
DataGridView CalendarColumn があります。デフォルトでは、データベース テーブルにバインドされている列が NULL の場合、現在の値が表示されますが、それも NULL にする必要があります。
たとえば、その特定の日付列のデータの場合、ユーザーが日付セルを空(NULL)にできるようにしたいのですが、これを実現するために設定するプロパティが見つかりません。DatagridviewのCalendercolumnでこの種の動作を実現することは、どんなアイデアでも可能です
public object EditingControlFormattedValue {
get {
if (this.ShowCheckBox && !this.Checked) {
return String.Empty;
} else {
if (this.Format == DateTimePickerFormat.Custom) {
return this.Value.ToString();
} else {
return this.Value.ToShortDateString();
}
}
}
set {
string newValue = value as string;
if (!String.IsNullOrEmpty(newValue)) {
this.Value = DateTime.Parse(newValue);
} else if (this.ShowCheckBox) {
this.Checked = false;
}
}
}
ctl.ShowCheckBox = this.isNullable;
if (this.Value != null && this.Value != DBNull.Value) {
if (this.Value is DateTime) {
ctl.Value = (DateTime)this.Value;
} else {
DateTime dtVal;
if (DateTime.TryParse(Convert.ToString(this.Value), out dtVal)) ctl.Value = dtVal;
}
if (this.isNullable) ctl.Checked = true;
} else if (this.isNullable) {
ctl.Checked = false;
}