public Dropdown(CheckedComboBox ccbParent) { _ccbParent = ccbParent; InitializeComponent(); ShowInTaskbar = false; // Add a handler to notify our parent of ItemCheck events. _cclb.ItemCheck += cclb_ItemCheck; }
/// <summary>获取控件的值 /// /// </summary> /// <param name="control">控件名称</param> /// <returns>值</returns> public static object GetOneValue(Control control) { if (control.GetType().ToString() == "Nikita.WinForm.ExtendControl.CheckedComboBox") { Nikita.WinForm.ExtendControl.CheckedComboBox cbkControlBox = (control as Nikita.WinForm.ExtendControl.CheckedComboBox); if (cbkControlBox != null) { return(cbkControlBox.CheckedItemValues); } } else if (control is System.Windows.Forms.TextBox) { return((control as System.Windows.Forms.TextBox).Text); } else if (control is System.Windows.Forms.CheckBox) { return((control as System.Windows.Forms.CheckBox).Checked); } else if (control is System.Windows.Forms.ComboBox) { return((control as System.Windows.Forms.ComboBox).SelectedValue); } else if (control is System.Windows.Forms.NumericUpDown) { return((control as System.Windows.Forms.NumericUpDown).Value); } else if (control is System.Windows.Forms.RadioButton) { return((control as System.Windows.Forms.RadioButton).Checked); } else if (control is System.Windows.Forms.RichTextBox) { return((control as System.Windows.Forms.RichTextBox).Text); } else if (control is System.Windows.Forms.CheckedListBox) { //CheckedListBox chkListBox = (control as System.Windows.Forms.CheckedListBox); //for (int i = 0; i < chkListBox.Items.Count; i++) //{ //} } //else if (control is System.Windows.Forms.DataGridView) //{ // DataGridView grdData = (control as System.Windows.Forms.DataGridView); // grdData.Rows.Clear(); // grdData.DataSource = null; //} //else if (control is System.Windows.Forms.TreeView) //{ // TreeView treeView = (control as System.Windows.Forms.TreeView); // treeView.Nodes.Clear(); //} return(null); }
/// <summary>清空单个控件输入 /// /// </summary> /// <param name="control">控件</param> private static void ClearOne(Control control) { if (control.GetType().ToString() == "Nikita.WinForm.ExtendControl.CheckedComboBox") { Nikita.WinForm.ExtendControl.CheckedComboBox cbkControlBox = (control as Nikita.WinForm.ExtendControl.CheckedComboBox); cbkControlBox.ClearChecked(); } else if (control is System.Windows.Forms.TextBox) { (control as System.Windows.Forms.TextBox).Text = string.Empty; } else if (control is System.Windows.Forms.CheckBox) { (control as System.Windows.Forms.CheckBox).Checked = false; } else if (control is System.Windows.Forms.ComboBox) { (control as System.Windows.Forms.ComboBox).SelectedIndex = -1; } else if (control is System.Windows.Forms.NumericUpDown) { (control as System.Windows.Forms.NumericUpDown).Value = 0; } else if (control is System.Windows.Forms.RadioButton) { (control as System.Windows.Forms.RadioButton).Checked = false; } else if (control is System.Windows.Forms.RichTextBox) { (control as System.Windows.Forms.RichTextBox).Text = string.Empty; } else if (control is System.Windows.Forms.CheckedListBox) { CheckedListBox chkListBox = (control as System.Windows.Forms.CheckedListBox); for (int i = 0; i < chkListBox.Items.Count; i++) { chkListBox.SetItemChecked(i, false); } } //else if (control is System.Windows.Forms.DataGridView) //{ // DataGridView grdData = (control as System.Windows.Forms.DataGridView); // grdData.Rows.Clear(); // grdData.DataSource = null; //} //else if (control is System.Windows.Forms.TreeView) //{ // TreeView treeView = (control as System.Windows.Forms.TreeView); // treeView.Nodes.Clear(); //} }
/// <summary>为控件绑定值 /// /// </summary> /// <param name="control">控件名称</param> /// <param name="objValue">值</param> public static void BindOne(Control control, object objValue) { if (control.GetType().ToString() == "Nikita.WinForm.ExtendControl.CheckedComboBox") { Nikita.WinForm.ExtendControl.CheckedComboBox cbkControlBox = (control as Nikita.WinForm.ExtendControl.CheckedComboBox); if (cbkControlBox != null && objValue != null) { cbkControlBox.SetItemCheckByValues(objValue.ToString()); } } else if (control is System.Windows.Forms.TextBox) { (control as System.Windows.Forms.TextBox).Text = objValue.ToString(); } else if (control is System.Windows.Forms.CheckBox) { bool blnValue = false; if (objValue != null) { if ((objValue.ToString() == "1" || objValue.ToString().ToLower() == "true")) { blnValue = true; } } (control as System.Windows.Forms.CheckBox).Checked = blnValue; } else if (control is System.Windows.Forms.ComboBox) { (control as System.Windows.Forms.ComboBox).SelectedValue = objValue; } else if (control is System.Windows.Forms.NumericUpDown) { if (objValue != null) { (control as System.Windows.Forms.NumericUpDown).Value = decimal.Parse(objValue.ToString()); } else { (control as System.Windows.Forms.NumericUpDown).Value = 0; } } else if (control is System.Windows.Forms.RadioButton) { bool blnValue = false; if (objValue != null) { if ((objValue.ToString() == "1" || objValue.ToString().ToLower() == "true")) { blnValue = true; } } (control as System.Windows.Forms.RadioButton).Checked = blnValue; } else if (control is System.Windows.Forms.RichTextBox) { if (objValue == null) { objValue = string.Empty; } (control as System.Windows.Forms.RichTextBox).Text = objValue.ToString(); } else if (control is System.Windows.Forms.CheckedListBox) { CheckedListBox chkListBox = (control as System.Windows.Forms.CheckedListBox); for (int i = 0; i < chkListBox.Items.Count; i++) { chkListBox.SetItemChecked(i, false); } } //else if (control is System.Windows.Forms.DataGridView) //{ // DataGridView grdData = (control as System.Windows.Forms.DataGridView); // grdData.Rows.Clear(); // grdData.DataSource = null; //} //else if (control is System.Windows.Forms.TreeView) //{ // TreeView treeView = (control as System.Windows.Forms.TreeView); // treeView.Nodes.Clear(); //} }