【发布时间】:2014-03-07 12:22:49
【问题描述】:
我的表单上有许多 Devexpress 控件,位于 layoutcontrol1 下。我用了 下面的代码遍历每个控件并在用户单击“清除”按钮时清除现有数据。但是,它不适用于 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]:stackoverflow.com/questions/14620375/… [2]:stackoverflow.com/questions/297526/…
标签: c# winforms user-controls devexpress