public static void SetControlValue(IEnumerable value, CheckedComboBox field) { if (value != null) { for (int i = 0, count = field.Items.Count; i < count; i++) { bool valuePresent = false; var listItem = ((ListItem)field.Items[i]); foreach (object item in value) { string val = item as string; if (item == null) { continue; } if (val.Trim() == listItem.Value) { valuePresent = true; break; } } field.SetItemChecked(i, valuePresent); } } else { for (int i = 0, count = field.Items.Count; i < count; i++) { field.SetItemChecked(i, false); } } }
void FillReaderStateDropDown(CheckedComboBox combobox) { // 防止重入 if (this.m_nInDropDown > 0) { return; } Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { if (combobox.Items.Count <= 0 && this.GetValueTable != null) { GetValueTableEventArgs e1 = new GetValueTableEventArgs(); e1.DbName = this.RefDbName; e1.TableName = "readerState"; this.GetValueTable(this, e1); if (e1.values != null) { for (int i = 0; i < e1.values.Length; i++) { combobox.Items.Add(e1.values[i]); } } else { // combobox.Items.Add("{not found}"); } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
public override void PipelineTabChanged(object sender, EventArgs e) { PipelineFilterCDORoot cdo = PipelineFilterCDO.CDO; if (cdo == null) { return; } TabControl tab = sender as TabControl; TabPage tabPage = tab.TabPages[tab.SelectedIndex]; Folder = tabPage.Controls.Find("cboFolder", true)[0] as CheckedComboBox; View = tabPage.Controls.Find("cboView", true)[0] as ComboBox; View.SelectedIndexChanged += View_SelectedIndexChanged; Control c = tabPage.Controls.Find("gradientPanel1", true).FirstOrDefault(); if (c != null && c.Controls.Find("save", true).Count().Equals(0)) { Filter = new ComboBox(); Label label = new Label(); Button save = new Button(); Button delete = new Button(); c.Controls.Add(label); c.Controls.Add(Filter); c.Controls.Add(save); c.Controls.Add(delete); Point p = c.Controls.Find("btnManageViews", true).FirstOrDefault().Location; label.Location = new Point(p.X + 20, p.Y); label.Text = "Filters"; label.Size = new Size(label.Size.Width / 2, label.Size.Height); Filter.Location = new Point(label.Location.X + label.Width + 5, label.Location.Y); Filter.SelectedValueChanged += Filter_SelectedValueChanged; save.Location = new Point(Filter.Location.X + Filter.Width + 5, Filter.Location.Y); save.Click += Save_Click; save.Text = "Save"; delete.Location = new Point(save.Location.X + save.Width + 5, save.Location.Y); delete.Click += Delete_Click; delete.Text = "Delete"; LoadFilters(Filter); } }
/// <summary>绑定自定义控件CheckedComboBox /// /// </summary> /// <param name="cbkCheckedComboBox">控件</param> /// <param name="dtSource">DataTable数据源</param> /// <param name="strDisplayMember">显示字段</param> /// <param name="strValueMember">值字段</param> /// <param name="intCheckedIndex">默认勾选项数组,从0开始</param> /// <param name="intMaxDropDownItems">最大项数</param> /// <param name="strValueSeparator">分隔符</param> public static void BindCheckedComboBox(CheckedComboBox cbkCheckedComboBox, DataTable dtSource, string strDisplayMember, string strValueMember, int[] intCheckedIndex = null, int intMaxDropDownItems = 5, string strValueSeparator = ",") { foreach (DataRow drRow in dtSource.Rows) { CCBoxItem item = new CCBoxItem(drRow[strDisplayMember].ToString(), drRow[strValueMember].ToString()); cbkCheckedComboBox.Items.Add(item); } cbkCheckedComboBox.MaxDropDownItems = intMaxDropDownItems; cbkCheckedComboBox.DisplayMember = strDisplayMember; cbkCheckedComboBox.ValueMember = strValueMember; cbkCheckedComboBox.ValueSeparator = strValueSeparator; if (intCheckedIndex != null) { for (int i = 0; i < intCheckedIndex.Length; i++) { cbkCheckedComboBox.SetItemChecked(i, true); } } }
private void checkedComboBox_filter_ItemChecked(object sender, ItemCheckedEventArgs e) { CheckedComboBox.ProcessItemChecked(e, "<无>"); }
private void checkedComboBox_operations_ItemChecked(object sender, ItemCheckedEventArgs e) { CheckedComboBox.ProcessItemChecked(e, "<全部>,<all>".ToLower()); }
private void comboBox_DropDown(object sender, EventArgs e) { if (this.m_nInDropDown > 0) { return; } Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { CheckedComboBox checked_combobox = null; ComboBox combobox = null; int nCount = 0; if (sender is CheckedComboBox) { checked_combobox = (CheckedComboBox)sender; nCount = checked_combobox.Items.Count; } else if (sender is ComboBox) { combobox = (ComboBox)sender; nCount = combobox.Items.Count; } else { throw new Exception("invalid sender type. must by ComboBox or CheckedComboBox"); } if (nCount == 0 /*&& this.GetValueTable != null*/) { GetValueTableEventArgs e1 = new GetValueTableEventArgs(); e1.DbName = this.BiblioDbName; // 2009/2/15 changed if (combobox == this.comboBox_type) { e1.TableName = "commentType"; // 评注类型 } else if (combobox == this.comboBox_orderSuggestion) { e1.TableName = "orderSuggestion"; // 订购建议 } else if (checked_combobox == this.checkedComboBox_state) { e1.TableName = "commentState"; // 评注状态 } else { Debug.Assert(false, "不支持的sender"); return; } // this.GetValueTable(this, e1); this.OnGetValueTable(this, e1); if (e1.values != null) { for (int i = 0; i < e1.values.Length; i++) { if (combobox != null) { combobox.Items.Add(e1.values[i]); } else { checked_combobox.Items.Add(e1.values[i]); } } } else { if (combobox != null) { combobox.Items.Add("<not found>"); } } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
private void valueTextChanged(object sender, EventArgs e) { this.Changed = true; string strControlName = ""; if (sender is TextBox) { TextBox textbox = (TextBox)sender; strControlName = textbox.Name; } else if (sender is ComboBox) { if (sender == this.comboBox_type) { #if NO Delegate_filterValue d = new Delegate_filterValue(FileterValue); this.BeginInvoke(d, new object[] { sender }); #endif Global.FilterValue(this, (Control)sender); } else if (sender == this.comboBox_orderSuggestion) { FilterValueEx(this, (Control)sender); } ComboBox combobox = (ComboBox)sender; strControlName = combobox.Name; } else if (sender is CheckedComboBox) { if (sender == this.checkedComboBox_state) { #if NO Delegate_filterValue d = new Delegate_filterValue(FileterValueList); this.BeginInvoke(d, new object[] { sender }); #endif Global.FilterValueList(this, (Control)sender); } CheckedComboBox combobox = (CheckedComboBox)sender; strControlName = combobox.Name; } else { Debug.Assert(false, "未处理的类型 " + sender.GetType().ToString()); return; } int nRet = strControlName.IndexOf("_"); if (nRet == -1) { Debug.Assert(false, "textbox名字中没有下划线"); return; } string strLabelName = "label_" + strControlName.Substring(nRet + 1) + "_color"; Label label = (Label)this.tableLayoutPanel_main.Controls[strLabelName]; if (label == null) { Debug.Assert(false, "没有找到名字为 '" + strLabelName + "' 的Label控件"); return; } label.BackColor = this.ColorChanged; }
void FillItemStateDropDown(CheckedComboBox combobox) { // 防止重入 if (this.m_nInDropDown > 0) { return; } Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { if (combobox.Items.Count <= 0 && this.GetValueTable != null) { GetValueTableEventArgs e1 = new GetValueTableEventArgs(); e1.DbName = this.RefDbName; e1.TableName = "state"; this.GetValueTable(this, e1); if (e1.values != null) { List <string> results = null; string strLibraryCode = ""; string strPureName = ""; string strLocationString = this.comboBox_location.Text; if (strLocationString == "<不改变>") { strLocationString = ""; } Global.ParseCalendarName(strLocationString, out strLibraryCode, out strPureName); if (String.IsNullOrEmpty(strLocationString) == false) { // 过滤出符合馆代码的那些值字符串 results = Global.FilterValuesWithLibraryCode(strLibraryCode, StringUtil.FromStringArray(e1.values)); } else { results = StringUtil.FromStringArray(e1.values); } foreach (string s in results) { combobox.Items.Add(s); } #if NO for (int i = 0; i < e1.values.Length; i++) { combobox.Items.Add(e1.values[i]); } #endif } else { // combobox.Items.Add("{not found}"); } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
void FillStateDropDown(CheckedComboBox combobox) { // 防止重入 if (this.m_nInDropDown > 0) { return; } #if NO string strTableName = ""; if (_stateActionCfg != null) { strTableName = _stateActionCfg.List; } #endif Cursor oldCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.m_nInDropDown++; try { if (combobox.Items.Count <= 0 && this.GetValueTable != null) { GetValueTableEventArgs e1 = new GetValueTableEventArgs(); e1.DbName = this.RefDbName; e1.TableName = this._actionCfg.List; #if NO if (this.DbType == "patron") { e1.TableName = "readerState"; } else if (this.DbType == "item") { e1.TableName = "state"; } else { e1.TableName = this.DbType + "State"; } #endif this.GetValueTable(this, e1); if (e1.values != null) { if (e1.TableName == "readerState" && e1.values.Length == 0) { e1.values = StringUtil.SplitList("注销,停借,挂失").ToArray(); } for (int i = 0; i < e1.values.Length; i++) { combobox.Items.Add(e1.values[i]); } } else { // combobox.Items.Add("{not found}"); } } } finally { this.Cursor = oldCursor; this.m_nInDropDown--; } }
private void InitModalities() { CheckedComboBox.FillModalities(comboBoxModalities); }
private void comboBox_seller_ItemChecked(object sender, ItemCheckedEventArgs e) { CheckedComboBox.ProcessItemChecked(e, "<全部>,<all>".ToLower()); CheckedComboBox.ProcessItemChecked(e, "<空>"); }