//清空查询 private void btnClear_Click(object sender, EventArgs e) { foreach (Control ctr in pnlSearch.Controls) { if (ctr is TextBoxEx) { TextBoxEx txt = (TextBoxEx)ctr; txt.Caption = string.Empty; } else if (ctr is ComboBoxEx) { ComboBoxEx cbo = (ComboBoxEx)ctr; if (cbo.Items.Count > 0) { cbo.SelectedIndex = 0; } else { cbo.SelectedItem = null; } } else if (ctr is TextChooser) { TextChooser txtc = (TextChooser)ctr; txtc.Text = string.Empty; txtc.Tag = null; } else if (ctr is CheckBox) { CheckBox cb = (CheckBox)ctr; cb.Checked = false; } else if (ctr is DateInterval) { DateInterval di = (DateInterval)ctr; di.Empty(); di.StartDate = DateTime.Now.ToString("yyyy-MM-01"); di.EndDate = DateTime.Now.ToString("yyyy-MM-dd"); } } }
/// <summary> /// 清除查询面板 /// </summary> /// <param name="pnlSearch">查询面板</param> public void ClearSearch(Panel pnlSearch) { foreach (Control ctr in pnlSearch.Controls) { if (ctr is TextBoxEx) { TextBoxEx txt = (TextBoxEx)ctr; txt.Caption = string.Empty; } else if (ctr is ComboBoxEx) { ComboBoxEx cbo = (ComboBoxEx)ctr; if (cbo.Items.Count > 0) { cbo.SelectedIndex = 0; } else { cbo.SelectedItem = null; } } else if (ctr is TextChooser) { TextChooser txtc = (TextChooser)ctr; txtc.Text = string.Empty; txtc.Tag = null; } else if (ctr is CheckBox) { CheckBox cb = (CheckBox)ctr; cb.Checked = false; } else if (ctr is DateInterval) { DateInterval di = (DateInterval)ctr; di.Empty(); } } }