我在layoutcontrol1下的表單上有許多Devexpress控件。我使用下面的代碼 來遍歷每個控件,並在用戶單擊「清除」按鈕時清除現有數據。但是,它在LookupEdit(將EditValue設置爲0)和CheckedListBoxControl(取消選中所有選定項目)上不起作用。如何清除表單數據
foreach (Control c in layoutControl1.Controls)
{
if (c.GetType() == typeof(TextEdit) || c.GetType()==typeof(MemoEdit))
c.Text = String.Empty;
if (c.GetType() == typeof(LookUpEdit))
c.EditValue = 0; //doesn't have EditValue property
if (c.GetType() == typeof(CheckedListBoxControl))
c.CheckedItems = CheckState.Unchecked; //doesn't have such property
}
有什麼建議嗎?
是指這樣一個問題:[?我們怎樣才能清除的WinForm的所有表單控件] [1] 或 [什麼是最好的方式清除上的形式C#所有控件] [2] 也許是有用的 [1]:http://stackoverflow.com/questions/14620375/how-can-we- clear-the-all-form-controls-on-winform [2]:http://stackoverflow.com/questions/297526/what-is-the-best-way-to-clear-all-controls-on -a-form -c –