我不認爲框架中內置了一個模式窗口。
您將不得不創建一個新的窗體。把日期選擇器放在上面。使其改性公衆和做這樣的事情:
private void MenuItemClick(objec sender, EventArgs e)
{
var userEnteredDate = DateTime.MinValue;
FormWithDate fmNewFormWithDateOnIt = new FormWithDate();
fmNewFormWithDateOnIt.ShowDialog();
userEnteredDate = fmNewFormWithDateOnIt.dtTimePickerOnForm.Value;
fmNewFormWithDateOnIt.Dispose()
//Do your thing
}
UPDATE:你可以把表單上的按鈕,並設置其的DialogResult = OK,然後執行以下操作:
if (fmNewFormWithDateOnIt.ShowDialog() == DialogResult.OK) //Not clicked the red close button on the form
{
userEnteredDate = fmNewFormWithDateOnIt.dtTimePickerOnForm.Value;
}
來源
2011-01-28 16:15:37
Jon
但如何我知道用戶是否更改了日期 - 這看起來好像只是在表單加載時從表單中獲取值,而不是等待用戶點擊好吧... – Elie 2011-01-28 16:21:59