private void SetSimpleVerification(string typeName, string memName, CheckedListBox chckLst) { int index1 = 0; int index2 = 0; try { index1 = chckLst.FindString(typeName); index2 = chckLst.FindString("\t" + memName, index1); } catch (Exception ex) { Console.WriteLine(ex.Message); } if (index2 > index1) { chckLst.SetItemChecked(index1, true); chckLst.SetItemChecked(index2, true); } }
public void LoadValue(HaloMap Map, int parentOffset) { uint num; fullOffset = parentOffset + BitmaskData.Offset; Map.IO.In.BaseStream.Position = fullOffset; HMap = Map; switch (BitmaskData.Attributes) { case mValue.ObjectAttributes.Bitmask8: num = Map.IO.In.ReadByte(); break; case mValue.ObjectAttributes.Bitmask16: num = Map.IO.In.ReadUInt16(); break; case mValue.ObjectAttributes.Bitmask32: num = Map.IO.In.ReadUInt32(); break; default: num = 0; break; } uint num2 = 1; for (int i = 0; i < _bitmaskdata.Options.Count; i++) { if ((num & num2) == num2) { lstBitOptions.SetItemChecked(i, true); } else { lstBitOptions.SetItemChecked(i, false); } num2 = num2 << 1; } Editted = false; }
private void ListBox_Itemcheck(object sender, ItemCheckEventArgs e) { if (ExclusiveSelection && e.NewValue == CheckState.Checked) { CheckedListBox tempWith1 = (CheckedListBox)ListBox; foreach (int idx in tempWith1.CheckedIndices) { tempWith1.SetItemChecked(idx, false); } } }
private void ChangeCheckOnList(CheckedListBox clb, int index, bool value) { if (clb.InvokeRequired) { var sbc = new SetBoolCallback(ChangeCheckOnList); Invoke(sbc, clb, index, value); } else { clb.SetItemChecked(index, !value); } }
public void BindCheckList(string strTable, CheckedListBox checklist, int i) {//绑定CheckList,参数“表”,“控件”,“列” conn.Open(); SqlCommand cmd = new SqlCommand("select * from " + strTable, conn); SqlDataReader sdr = cmd.ExecuteReader(); if (sdr.Read() == true) { if (string.Format("{0}", sdr[i]) == "男") { checklist.SetItemChecked(0, true); checklist.SetItemChecked(1, false); } else { checklist.SetItemChecked(0, false); checklist.SetItemChecked(1, true); } } conn.Close(); }
private void UpdateChkList(CheckedListBox chkLst, Shape shape) { chkLst.Items.Clear(); int intCount = shape.GDIPropertyCount; for (short i = 0; i < intCount; i++) { chkLst.Items.Add(shape.GetPropertyName(i)); chkLst.SetItemChecked(i, (bool)shape.GetGDIValue(i)); } }
private void UpdateCheckedList(CheckedListBox list) { object wasSelected = list.SelectedItem; list.BeginUpdate(); for (int i = 0; i < list.Items.Count; i++) { list.SetItemChecked(i, ((Item)list.Items[i]).IsVisible); } list.SelectedItem = wasSelected; list.EndUpdate(); }
public static void FillFlagTableArray(CheckedListBox clb, byte[] data) { for (int idx = 0; idx < data.Length; idx++) { for (int i = 0; i < 8; i++) { var index = (idx * 8) + i; clb.SetItemChecked(index, (data[idx] & (1 << (i))) > 0); } } }
void OnListCloseUp(object sender, System.EventArgs e) { if (Cancelled) { for (int index = 0; index < Items.Count; index++) { m_ListBox.SetItemChecked(index, Array.Exists(m_PrevCheckedIndices, item => item == index)); } } m_PrevCheckedIndices = null; }
private void InitCheckList(CheckedListBox list, string [] values) { list.Items.Clear( ); if (values != null) { list.Items.AddRange(values); } for (int i = 0; i < list.Items.Count; i++) { list.SetItemChecked(i, true); } }
public void changechecklistbox(CheckedListBox cb, int item, bool check) { if (cb.InvokeRequired) { changechecklistboxcallback Db = new changechecklistboxcallback(changechecklistbox); cb.BeginInvoke(Db, new object[] { cb, item, check }); } else { cb.SetItemChecked(item, check); } }
void selectAllButton_Click(object sender, EventArgs e) { foreach (Control control in splitContainer1.Panel2.Controls) { if (control.GetType() == typeof(CheckedListBox)) { CheckedListBox checkedlistBox = (CheckedListBox)control; for (int i = 1; i < checkedlistBox.Items.Count; i++) checkedlistBox.SetItemChecked(i, true); } } }
private void ChangeCheckAllStatus([NotNull] CheckedListBox control, bool checkedStatus) { int count = control.Items.Count; if (count > 0) { for (int i = 0; i < count; i++) { control.SetItemChecked(i, checkedStatus); } } }
// Check the specified value in the list box private void CheckItem(CheckedListBox listBox, TEnum value) { int length = nameValues.Length; for (int index = 0; index < length; index++) { if (nameValues[index].Value.Equals(value)) { listBox.SetItemChecked(index, true); } } }
public OptionsPicker() { InitializeComponent(); InitializeDropDown(fCheckedListBox); string[] myFruit = { "Apples", "Oranges", "Tomato" }; fCheckedListBox.Items.AddRange(myFruit); for (int i = 0; i < fCheckedListBox.Items.Count; i++) { fCheckedListBox.SetItemChecked(i, false); } }
/// <summary> /// Adds a useful context menu to a checked list box /// </summary> public static void AddContextMenu(this CheckedListBox clb) { var menu = new ContextMenu(); menu.MenuItems.Add(new MenuItem("Check all", (sender, args) => { for (int i = 0; i < clb.Items.Count; i++) { clb.SetItemChecked(i, true); } })); menu.MenuItems.Add(new MenuItem("Uncheck all", (sender, args) => { for (int i = 0; i < clb.Items.Count; i++) { clb.SetItemChecked(i, false); } })); clb.ContextMenu = menu; }
private void SetSelectionFromString( string selection ) { string[] selectedValues = SelectionStringToArray(selection); for (int i = 0; i < CheckedListBox.Items.Count; i++) { CheckedListBox.SetItemChecked(i, IsItemInSelection(selectedValues, i)); } }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { int i; //instantiate the custom property editor service provider es = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (es != null) { //load the ListBox items from vesseldata and check them appropriately cbx.Items.Clear(); cbx.Sorted = false; //dont sort while adding foreach (string item in VesselData.Current.RaceKeys) { cbx.Items.Add(item); if (value != null) { if (((string)value).Split(' ').Contains(item)) { cbx.SetItemChecked(cbx.Items.Count - 1, true); } } } cbx.Sorted = true; cbx.CheckOnClick = true; //show the control and wait for user input es.DropDownControl(cbx); //Apply values to a temp list and return it List <string> tmp = new List <string>(); for (i = 0; i < cbx.Items.Count; i++) { if (cbx.GetItemChecked(i)) { tmp.Add(cbx.Items[i].ToString()); } } if (tmp.Count == 0) { return(""); } else { return(tmp.Aggregate((alfa, beta) => alfa + " " + beta)); } } return(null); }
private void ChangeStatus([NotNull] CheckedListBox listBox, bool check) { var count = listBox.Items.Count; if (count > 0) { for (int i = 0; i < count; i++) { listBox.SetItemChecked(i, check); } } }
private void SetItemState(CheckedListBox list, bool state, bool update) { for (int i = 0; i < list.Items.Count; i++) { list.SetItemChecked(i, state); } if (update) { SystemService.ConfigSelectEmpleados(); } }
internal static void AllowOnlyOneCheckedItem(object sender, ItemCheckEventArgs e) { CheckedListBox listBox = (CheckedListBox)sender; if (e.NewValue == CheckState.Checked) { foreach (int i in listBox.CheckedIndices) { listBox.SetItemChecked(i, false); } } }
public void Marcar_Desmarcar(int indice, CheckedListBox lista, Button btn) { if (bandera[indice]) { for (int x = 0; x < lista.Items.Count; x++) { lista.SetItemChecked(x, true); } bandera[indice] = false; btn.Text = "Desmarcar todos."; } else { for (int x = 0; x < lista.Items.Count; x++) { lista.SetItemChecked(x, false); } bandera[indice] = true; btn.Text = "Marcar todos."; } }
protected void LoadSettings(string section) { string strFilters = ""; string strUsedFilters = ""; cLBDSFilter.Sorted = false; lBDSFilter.Sorted = false; cLBDSFilter.DisplayMember = "Name"; lBDSFilter.DisplayMember = "Name"; lBDSFilter.FormattingEnabled = true; using (Settings xmlreader = new MPSettings()) { int intCount = 0; while (xmlreader.GetValueAsString(section, "filter" + intCount.ToString(), "undefined") != "undefined") { strFilters += xmlreader.GetValueAsString(section, "filter" + intCount.ToString(), "undefined") + ";"; if (xmlreader.GetValueAsBool(section, "usefilter" + intCount.ToString(), false)) { strUsedFilters += xmlreader.GetValueAsString(section, "filter" + intCount.ToString(), "undefined") + ";"; } intCount++; } } foreach (DsDevice device in DsDevice.GetDevicesOfCat(FilterCategory.LegacyAmFilterCategory)) { try { if (device.Name != null) { lBDSFilter.Items.Add(device); foreach (string filter in strFilters.Split(';')) { if (filter.Equals(device.Name)) { cLBDSFilter.Items.Add(device); cLBDSFilter.SetItemChecked(cLBDSFilter.Items.Count - 1, strUsedFilters.Contains(device.Name)); } } } } catch (Exception) {} } cLBDSFilter.Sorted = true; lBDSFilter.Sorted = true; if (cLBDSFilter.Items.Count > 0) { cLBDSFilter.SelectedIndex = 0; } if (lBDSFilter.Items.Count > 0) { lBDSFilter.SelectedIndex = 0; } }
public void LoadDataEditItem(TextBox ProductNameEd, TextBox ProductIdEd, TextBox DesignCodeEd, ComboBox ColorEd, MaskedTextBox NumberOfPiecesEd, MaskedTextBox QuantityInStockEd, MaskedTextBox ProductPriceEd, ComboBox KameezFabricEd, ComboBox ShalwarFabricEd, ComboBox DupattaFabricEd, CheckedListBox EmbroideryStatusEd, PictureBox ProductImageEd) { //this will load data to edit item window.... ProductNameEd.Text = p1.PRODUCT_NAME; ProductIdEd.Text = p1.PRODUCT_ID; DesignCodeEd.Text = p1.DESIGN_CODE; ColorEd.Text = p1.COLOR; NumberOfPiecesEd.Text = p1.NUMBER_OF_PIECES.ToString(); QuantityInStockEd.Text = p1.QUANTITY_IN_STOCK.ToString(); ProductPriceEd.Text = p1.PRODUCT_PRICE.ToString(); KameezFabricEd.Text = p1.KAMEEZFABRIC; ShalwarFabricEd.Text = p1.SHALWAR_FABRIC; DupattaFabricEd.Text = p1.DUPATTA_FABRIC; EmbroideryStatusEd.SetItemChecked(0, p1.IS_KAMEEZ_FRONT_EMBROIDED); EmbroideryStatusEd.SetItemChecked(1, p1.IS_KAMEEZ_BACK_EMBROIDED); EmbroideryStatusEd.SetItemChecked(2, p1.IS_DUPATTA_EMBROIDED); EmbroideryStatusEd.SetItemChecked(3, p1.IS_SHALWAR_EMBROIDED); ProductImageEd.Image = Image.FromFile(p1.IMAGE_PATH); ProductImageEd.SizeMode = PictureBoxSizeMode.StretchImage; ProductImageEd.ImageLocation = p1.IMAGE_PATH; }
/// <summary> /// 设置ListBox是选中 /// </summary> /// <param name="clb"></param> /// <param name="allOrEmpty"></param> private void SetListChecked(CheckedListBox clb, bool allOrEmpty) { int itemCount = clb.Items.Count; if (itemCount > 0) { for (int i = 0; i < itemCount; i++) { clb.SetItemChecked(i, allOrEmpty); } } }
public void ModelToView() { // TODO: There is a BUG in CheckedListBox. It was not designed for // DataBinding and therefore does not work under this condition. // The workaround is to insert the CheckedListBox population // manually. //ListBox.DataSource = DomainValues ListBox.DisplayMember = "Designacao"; ListBox.Items.Clear(); DataRowView lastDr = null; foreach (DataRowView dr in new DataView(DomainValues, "", "Designacao", DataViewRowState.CurrentRows)) { if ("Outra".Equals(dr["Designacao"]) || "Outro".Equals(dr["Designacao"])) { lastDr = dr; } else { ListBox.Items.Add(dr); } } if (lastDr != null) { ListBox.Items.Add(lastDr); } int i = 0; DataRowView row2 = null; foreach (DataRowView row in Selection) { for (i = 0; i < ListBox.Items.Count; i++) { row2 = (DataRowView)(ListBox.Items[i]); if (ListBox is CheckedListBox) { CheckedListBox tempWith1 = (CheckedListBox)ListBox; if (row[SelectionColumn].Equals(row2["ID"])) { tempWith1.SetItemChecked(i, true); } } else { if (row[SelectionColumn].Equals(row2["ID"])) { ListBox.SetSelected(i, true); } } } } }
public static void Show(ref List <IAppTask> tasks) { using Form tmp = new Form { Size = new Size(600, 300) }; using CheckedListBox list = new CheckedListBox { Dock = DockStyle.Fill }; list.Items.AddRange(tasks.ToArray()); for (int i = 0; i < tasks.Count; i++) { list.SetItemChecked(i, true); } tmp.Controls.Add(list); tmp.ShowDialog(); tasks = list.Items.OfType <IAppTask>().Where((s, i) => list.GetItemChecked(i)).ToList(); }
/// <summary> /// 设置选择项 /// </summary> public void SetSelectValue(List <string> listSelect) { for (int i = 0; i < checkListBox.Items.Count; i++) { checkListBox.SetItemChecked(i, false); } ClearSelectValue(); if (listSelect == null || listSelect.Count == 0) { return; } string temp = ""; for (int i = 0; i < checkListBox.Items.Count; i++) { temp = checkListBox.GetItemText(checkListBox.Items[i]); if (listSelect.Contains(temp)) { checkListBox.SetItemChecked(i, true); } } }
private void LoadListBoxItems() { cbx.Items.Clear(); cbx.Items.Add(Localizer.GetString("TitleCourse")); var chart = ((BaseChartIndicator)indi).owner.Owner; foreach (var i in chart.indicators) { if (i == indi) { continue; } foreach (var ser in i.SeriesResult) { cbx.Items.Add(i.UniqueName + Separators.IndiNameDelimiter[0] + ser.Name); } } //cbx.SelectedItem = indi.SeriesSourcesDisplay; if (string.IsNullOrEmpty(indi.SeriesSourcesDisplay)) { return; } var items = indi.SeriesSourcesDisplay.Split(Separators.SourcesDelimiter, StringSplitOptions.None); foreach (var item in items) { for (var i = 0; i < cbx.Items.Count; i++) { if ((string)cbx.Items[i] != item) { continue; } // совпало, отмечаем cbx.SetItemChecked(i, true); i = cbx.Items.Count; } } }
public static void Draw(CheckedListBox list) { list.BeginUpdate(); list.Items.Clear(); for (int i = 0; i < m_Filters.Count; i++) { Filter f = (Filter)m_Filters[i]; list.Items.Add(f); list.SetItemChecked(i, f.Enabled); } list.EndUpdate(); }
private void showEditParams(String[] urlParams) { paramsForm = new Form(); paramsForm.Width = 560; paramsForm.Height = 440; paramsForm.Text = "Please select parameters to edit.."; paramsForm.FormBorderStyle = FormBorderStyle.FixedDialog; paramsForm.StartPosition = FormStartPosition.CenterParent; paramsForm.MinimizeBox = false; paramsForm.MaximizeBox = false; // add url label TextBox txtUrl = new TextBox(); txtUrl.ReadOnly = true; txtUrl.Location = new Point(20, 10); txtUrl.Width = paramsForm.Width - 40; txtUrl.Text = editWithSession.fullUrl; paramsForm.Controls.Add(txtUrl); // jsonp type option chkJsonp = new CheckBox(); chkJsonp.Text = "Is this a JSONP request? I'll replace response body with the value you selected."; chkJsonp.Location = new Point(20, 40); chkJsonp.Width = paramsForm.Width - 40; chkJsonp.BackColor = Color.DarkOrange; paramsForm.Controls.Add(chkJsonp); // add params ui paramList = new CheckedListBox(); paramList.Location = new Point(20, 70); paramList.Width = paramsForm.Width - 40; paramList.Height = 300; paramList.Items.AddRange(urlParams); //paramList.CheckOnClick = true; for (int i = 0; i < paramList.Items.Count; i++) { paramList.SetItemChecked(i, true); } paramsForm.Controls.Add(paramList); // add "Edit it!" button Button btn_go = new Button(); btn_go.Text = "Edit it!"; btn_go.Width = 250; btn_go.Height = 22; btn_go.Location = new Point(paramsForm.Width / 2 - btn_go.Width / 2, 370); btn_go.Click += new EventHandler(this.OnFeditParamsWithClick); paramsForm.Controls.Add(btn_go); paramsForm.AcceptButton = btn_go; paramList.Focus(); paramsForm.ShowDialog(); }