public void ClearControl(Form form){ Control ct1, com1; foreach (ct1 in form.Controls) { if (ct1 is DevExpress.XtraEditors.TextEdit) { ct1.Text = ""; } if (ct1 is DevExpress.XtraEditors.ComboBox){ ct1.Text = ""; } if (ct1 is GroupBox) { foreach (com1 in ct1.Controls) { if (com1 is DevExpress.XtraEditors.TextEdit) { com1.Text = ""; } if (com1 is DevExpress.XtraEditors.ComboBox){ com1.Text = ""; } } } } }
不好意思,犯了个错误: public void ClearControl(Form form){ foreach (Control ct1 in form.Controls) { if (ct1 is DevExpress.XtraEditors.TextEdit) { ct1.Text = ""; } if (ct1 is DevExpress.XtraEditors.ComboBox){ ct1.Text = ""; } if (ct1 is GroupBox) { foreach (Control com1 in ct1.Controls) { if (com1 is DevExpress.XtraEditors.TextEdit) { com1.Text = ""; } if (com1 is DevExpress.XtraEditors.ComboBox){ com1.Text = ""; } } } } }
Control ct1, com1;
DevExpress.XtraEditors.TextEdit txtTmp;
DevExpress.XtraEditors.ComboBox cbTmp;
GroupBox grpTmp;
foreach(ct1 in form.Controls)
{
if(TypeOf(ct1)==TypeOf(txtTmp))
ct1.Text = ""
if(TypeOf(ct1)==TypeOf(cbTmp))
ct1.Text = ""
if(TypeOf(ct1)==TypeOf(grpTmp))
{
foreach(com1 in ct1.Controls)
{
if(TypeOf(ct1)==TypeOf(txtTmp))
ct1.Text = ""
if(TypeOf(ct1)==TypeOf(cbTmp))
ct1.Text = ""
}
}
}
}
{
Control ctl,coml;
foreach(Control in form.Controls)
{
if(ctl.GetType() == TextBox)
{
ctl.Text = "";
}
else if(ctl.GetType() == ComboBox)
{
ctl.Text = "";
}
else if(ctl.GetType() == GroupBox)
{
foreach(Control coml in ctl.Controls)
{
if(coml.GetType() == TextBox)
{
coml.Text = "";
}
else if(coml.GetType() == ComboBox)
{
coml.Text = "";
}
}
}}
}
Control ct1, com1;
foreach (ct1 in form.Controls) {
if (ct1 is DevExpress.XtraEditors.TextEdit) {
ct1.Text = "";
}
if (ct1 is DevExpress.XtraEditors.ComboBox){
ct1.Text = "";
} if (ct1 is GroupBox) {
foreach (com1 in ct1.Controls) {
if (com1 is DevExpress.XtraEditors.TextEdit) {
com1.Text = "";
}
if (com1 is DevExpress.XtraEditors.ComboBox){
com1.Text = "";
}
}
}
}
}
public void ClearControl(Form form){
foreach (Control ct1 in form.Controls) {
if (ct1 is DevExpress.XtraEditors.TextEdit) {
ct1.Text = "";
}
if (ct1 is DevExpress.XtraEditors.ComboBox){
ct1.Text = "";
} if (ct1 is GroupBox) {
foreach (Control com1 in ct1.Controls) {
if (com1 is DevExpress.XtraEditors.TextEdit) {
com1.Text = "";
}
if (com1 is DevExpress.XtraEditors.ComboBox){
com1.Text = "";
}
}
}
}
}