private void checkRubricBox_ItemCheck(object sender, EventArgs e) { if (changeByProgram) { return; } changeByProgram = true; CheckedListBox checkBox = (CheckedListBox)sender; checkBox.SetItemChecked(checkBox.SelectedIndex, !checkBox.GetItemChecked(checkBox.SelectedIndex)); if (checkBox.SelectedIndex == 0) { for (int i = 1; i < checkBox.Items.Count; i++) { checkBox.SetItemChecked(i, checkBox.GetItemChecked(0)); } changeByProgram = false; return; } bool allCheck = true; for (int i = 1; i < checkBox.Items.Count; i++) { if (checkBox.GetItemChecked(i) == false) { allCheck = false; break; } } checkBox.SetItemChecked(0, allCheck); changeByProgram = false; }
private void CbxKeyDown(Object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { var selIndex = cbx.SelectedIndex; if (selIndex <= 0) { return; } var isChecked = cbx.GetItemChecked(selIndex); var obj = cbx.Items[selIndex]; cbx.Items.RemoveAt(selIndex); cbx.Items.Insert(selIndex - 1, obj); cbx.SetItemChecked(selIndex - 1, isChecked); cbx.SelectedIndex = selIndex; } if (e.KeyCode == Keys.Down) { var selIndex = cbx.SelectedIndex; if (selIndex <= 0 || selIndex == cbx.Items.Count - 1) { return; } var isChecked = cbx.GetItemChecked(selIndex); var obj = cbx.Items[selIndex]; cbx.Items.RemoveAt(selIndex); cbx.Items.Insert(selIndex + 1, obj); cbx.SetItemChecked(selIndex + 1, isChecked); cbx.SelectedIndex = selIndex + 1; } }
public Boolean AddSpecified(CheckedListBox List) { int cnt = 0; for (int i = 0; i <= (List.Items.Count - 1); i++) { if (List.GetItemChecked(i)) { cnt = (i + 1); } } if (cnt >= 2) { for (i = 0; i <= (List.Items.Count - 1); i++) { if (List.GetItemChecked(i)) { SortList.Add(List.Items[i].ToString()); } } return(true); } else { MessageBox.Show("2つ以上の選択が必要", "Error"); return(false); } }
// 返回选择框中被选中的记录 public string[] SelectedStrs(CheckedListBox CLB) { int SelectedNum = 0; for (int i = 0; i < CLB.Items.Count; i++) { if (CLB.GetItemChecked(i)) { SelectedNum++; } } //MessageBox.Show(SelectedNum.ToString()); if (SelectedNum == 0) { return(null); } else { string[] Cores = new string[SelectedNum]; int j = 0; for (int i = 0; i < CLB.Items.Count; i++) { if (CLB.GetItemChecked(i)) { Cores[j] = CLB.GetItemText(CLB.Items[i]); //MessageBox.Show(Cores[j]); j++; CLB.SetItemCheckState(i, CheckState.Unchecked); } } return(Cores); } }
private void listDown(CheckedListBox listBox) { if (listBox.SelectedIndex == -1 || listBox.SelectedIndex == listBox.Items.Count - 1) { return; } object selected; object next; object temp; bool selectedChecked; bool nextChecked; bool tempChecked; selected = listBox.Items[listBox.SelectedIndex]; selectedChecked = listBox.GetItemChecked(listBox.SelectedIndex); next = listBox.Items[listBox.SelectedIndex + 1]; nextChecked = listBox.GetItemChecked(listBox.SelectedIndex + 1); temp = selected; tempChecked = selectedChecked; selected = next; selectedChecked = nextChecked; next = temp; nextChecked = tempChecked; listBox.Items[listBox.SelectedIndex] = selected; listBox.SetItemChecked(listBox.SelectedIndex, selectedChecked); listBox.Items[listBox.SelectedIndex + 1] = next; listBox.SetItemChecked(listBox.SelectedIndex + 1, nextChecked); listBox.SelectedIndex++; }
void OFormActMain_OnLogLineRead(bool isImport, LogLineEventArgs logInfo) { if (isImport && !sessionStart) { return; } string tlogline = logInfo.logLine; Match match = Regex.Match(tlogline, "^.{14} 00:.{4}:(?<Player>.*?)获得了“(?<ItemName>.*?)(?”)×(?<ItemNum>.*?)。$"); if (match.Success) { for (int itemIndex = 0; itemIndex < ItemList.Items.Count; itemIndex++) { if (ItemList.GetItemChecked(itemIndex) && match.Groups[1] == ItemList.Items[itemIndex]) { ItemCount.Items[itemIndex] += match.Groups[2].Value; } } } match = Regex.Match(tlogline, "^.{14} 01:Changed Zone to 梦羽宝境.$"); if (match.Success) { for (int itemIndex = 0; itemIndex < ItemList.Items.Count; itemIndex++) { if (ItemList.GetItemChecked(itemIndex) && match.Groups[1] == ItemList.Items[itemIndex]) { ItemCount.Items[itemIndex] += match.Groups[2].Value; } } } }
private void listUp(CheckedListBox listBox) { if (listBox.SelectedIndex == -1 || listBox.SelectedIndex == 0) { return; } object selected; object previous; object temp; bool selectedChecked; bool previousChecked; bool tempChecked; selected = listBox.Items[listBox.SelectedIndex]; selectedChecked = listBox.GetItemChecked(listBox.SelectedIndex); previous = listBox.Items[listBox.SelectedIndex - 1]; previousChecked = listBox.GetItemChecked(listBox.SelectedIndex - 1); temp = selected; tempChecked = selectedChecked; selected = previous; selectedChecked = previousChecked; previous = temp; previousChecked = tempChecked; listBox.Items[listBox.SelectedIndex] = selected; listBox.SetItemChecked(listBox.SelectedIndex, selectedChecked); listBox.Items[listBox.SelectedIndex - 1] = previous; listBox.SetItemChecked(listBox.SelectedIndex - 1, previousChecked); listBox.SelectedIndex--; }
private void btnSelectInverse_Click(object sender, EventArgs e) { for (int i = 0; i < chkMultipleValuesSelect.Items.Count; i++) { chkMultipleValuesSelect.SetItemChecked(i, !chkMultipleValuesSelect.GetItemChecked(i)); } }
public static void ActualizarPermisosEnBase(CheckedListBox checklistaPermisos, string idUsuario) { try { Data_Persistance.Conexion.CerrarConexion(); Data_Persistance.Conexion.AbrirConexion(); string sentencia; SqlCommand cm = new SqlCommand("", Data_Persistance.Conexion.conn); for (int i = 1; i < checklistaPermisos.Items.Count + 1; i++) { if (checklistaPermisos.GetItemChecked(i - 1) == true) { sentencia = "BEGIN IF NOT EXISTS (SELECT *FROM Permiso_Usuario WHERE Id_Usuario ='" + idUsuario + "' AND Id_Permiso ='" + i + "') BEGIN INSERT Permiso_Usuario (Id_Usuario, Id_Permiso) VALUES ('" + idUsuario + "', '" + i + "') END END"; cm = new SqlCommand(sentencia, Data_Persistance.Conexion.conn); cm.ExecuteNonQuery(); } else if (checklistaPermisos.GetItemChecked(i - 1) == false) { sentencia = "BEGIN IF EXISTS (SELECT *FROM Permiso_Usuario WHERE Id_Usuario ='" + idUsuario + "' AND Id_Permiso ='" + i + "') BEGIN DELETE FROM Permiso_Usuario WHERE Id_Usuario = '" + idUsuario + "' AND Id_Permiso ='" + i + "' END END"; cm = new SqlCommand(sentencia, Data_Persistance.Conexion.conn); cm.ExecuteNonQuery(); } } } catch (Exception error) { throw error; } finally { Data_Persistance.Conexion.CerrarConexion(); } }
List <T> GetCheckedItems <T>(CheckedListBox listBox) { List <T> checkedItems = new List <T>(); for (int i = 0; i < listBox.Items.Count; i++) { if ((listBox.GetItemChecked(i) && i != listBox.SelectedIndex) || (!listBox.GetItemChecked(i) && i == listBox.SelectedIndex)) { checkedItems.Add((T)listBox.Items[i]); } } return(checkedItems); }
private void EnumFlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e) { if (_ocrEngine == null || !_ocrEngine.IsStarted) { return; } CheckedListBox clb = sender as CheckedListBox; string settingName = clb.Tag.ToString(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < clb.Items.Count; i++) { if (i != e.Index) { if (clb.GetItemChecked(i)) { sb.Append(clb.Items[i] + ", "); } } else if (e.NewValue == CheckState.Checked) { sb.Append(clb.Items[i] + ", "); } } if (sb.Length > 0) { sb.Remove(sb.Length - 2, 2); } SetSettingValue(settingName, sb.ToString()); }
private void btn_Click(object sender, EventArgs e) { try { bool check; for (int i = 0; i < lstbox.Items.Count; i++) { check = lstbox.GetItemChecked(i); if (check) { strs[i] = "1"; } else { strs[i] = "0"; } } reader.WriteXML(strs); reader.Save(); Macros.StandardAddInServer.settings(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
void MoveItem(CheckedListBox list, int direction) { // Checking selected item if (list.SelectedItem == null || list.SelectedIndex < 0) { return; // No selected item - nothing to do } // Calculate new index using move direction int newIndex = list.SelectedIndex + direction; // Checking bounds of the range if (newIndex < 0 || newIndex >= list.Items.Count) { return; // Index out of range - nothing to do } object selected = list.SelectedItem; bool checkedBox = list.GetItemChecked(list.SelectedIndex); // Removing removable element list.Items.Remove(selected); // Insert it in new position list.Items.Insert(newIndex, selected); // Restore selection list.SetSelected(newIndex, true); //Restored Checkbox list.SetItemChecked(newIndex, checkedBox); }
private static void CheckAndUpdateDebugUI(DeviceContext context, CSharpRendererMainForm form) { ComboBox cb = form.GetDebugSurface(); ComboBox cbM = form.GetDebugMode(); CheckedListBox features = form.GetFeatureCLB(); if (DebugManager.m_IsUIRebuildRequired) { cb.Items.Clear(); cb.Items.AddRange(DebugManager.m_AvailableModes.ToArray()); features.Items.Clear(); foreach (var pair in DebugManager.m_AvailableFeatures) { features.Items.Add(pair.Key, pair.Value); } DebugManager.m_IsUIRebuildRequired = false; cbM.SelectedIndex = 0; cb.SelectedIndex = 0; } if (cb.SelectedIndex >= 0 && form.GetDebugModeOn()) { DebugManager.m_CurrentDebugSurface = (string)cb.Items[cb.SelectedIndex]; DebugManager.m_CurrentDebugMode = cbM.SelectedIndex > 0 ? (string)cbM.Items[cbM.SelectedIndex] : "RGB"; } else { DebugManager.m_CurrentDebugSurface = "None"; } if (m_TakeSnapshot) { DebugManager.m_TakeSnapshot = true; m_TakeSnapshot = false; } int counter = 0; string[] featuresArrayCopy = new string[DebugManager.m_AvailableFeatures.Keys.Count]; DebugManager.m_AvailableFeatures.Keys.CopyTo(featuresArrayCopy, 0); foreach (var key in featuresArrayCopy) { bool uiValue = features.GetItemChecked(counter++); DebugManager.m_AvailableFeatures[key] = uiValue; } DebugManager.m_ShowSnapshot = form.GetShowSnapshot(); DebugManager.m_ShowSnapshotDifference = form.GetShowSnapshotDifference(); if (DebugManager.m_GPUDebugOn) { form.GetGPUDebuggingTB().Text = DebugManager.GetDebugString(context); } DebugManager.SetGPUDebugMode(form.GetGPUDebugModeOn()); DebugManager.m_DisabledTemporal = form.GetDisabledTemporal(); }
public static void AgregarSintomasAMedicamento(CheckedListBox CheckSintomas, int IdMedicamento) { try { Data_Persistance.Conexion.CerrarConexion(); Data_Persistance.Conexion.AbrirConexion(); for (int i = 1; i < CheckSintomas.Items.Count + 1; i++) { if (CheckSintomas.GetItemChecked(i - 1) == true) { SqlCommand cm = new SqlCommand("Insertar_Sintoma_Medicamento", Data_Persistance.Conexion.conn); cm.CommandType = CommandType.StoredProcedure; cm.Parameters.Add(new SqlParameter("@Id_Sintoma", i)); cm.Parameters.Add(new SqlParameter(@"Id_Medicamento", IdMedicamento)); cm.ExecuteNonQuery(); } } } catch (Exception) { throw; } finally { Data_Persistance.Conexion.CerrarConexion(); } }
private void InvertChecked(CheckedListBox lst) { for (int index = 0; index < lst.Items.Count; ++index) { lst.SetItemChecked(index, !lst.GetItemChecked(index)); } }
// Запомнить чекбоксы фильтра private void SaveChkFilter() { string col = this.Columns[ColumnIndex].Name; string itemChk; bool statChk; Filter.RemoveAll(x => x.columnName == col); Filter.RemoveAll(x => x.columnName != col && !x.check); if (CheckLB.CheckedItems.Count < CheckLB.Items.Count) { this.Columns[ColumnIndex].HeaderCell.Style.BackColor = CheckedColor; } else { this.Columns[ColumnIndex].HeaderCell.Style.BackColor = UnCheckedColor; } for (int i = 1; i < CheckLB.Items.Count; i++) { itemChk = CheckLB.Items[i].ToString(); statChk = CheckLB.GetItemChecked(i); Filter.Add(new FilterStatus() { columnName = col, valueString = itemChk, check = statChk }); } }
private void m_cmd_search_Click(object sender, EventArgs e) { try { ma_cv = ""; for (int i = 0; i < m_clb_chuc_vu.Items.Count; i++) { if (m_clb_chuc_vu.GetItemChecked(i)) { ma_cv = string.Concat(ma_cv, m_clb_chuc_vu.Items[i].ToString()); } } load_data_2_grid_search(); /*if (m_txt_tim_kiem.Text.Trim() == "Nhập mã chức vụ, mã nhân viên, họ tên") * { * m_txt_tim_kiem.Text = ""; * load_data_2_grid_search(); * m_txt_tim_kiem.Text = "Nhập mã chức vụ, mã nhân viên, họ tên"; * } * else * load_data_2_grid_search();*/ } catch (Exception v_e) { CSystemLog_301.ExceptionHandle(v_e); } }
public static void AntonymChecked(CheckedListBox checklistBox) { for (var i = 0; i < checklistBox.Items.Count; i++) { checklistBox.SetItemChecked(i, !checklistBox.GetItemChecked(i)); } }
public string ProcessMessage(string speaker, string command, string[] arguments) { if (command == "!playsound") { if (!isEnabled()) { return($"Sorry {speaker} this command is currently disabled."); } if (arguments.Length <= 0) { return(GetSoundToolTip()); } string soundPath = GetSoundPathFromFileName(arguments[0]); if (SoundExists(arguments[0]) && soundPath != null) { int index = GetSoundIndex(soundPath); if (!soundsList.GetItemChecked(index)) { return($"Sorry {speaker}, that sound is currently disabled."); } SoundPlayer player = new SoundPlayer(soundPath); player.Play(); return(null); } else { return($"Sorry {speaker}, I was unable to play the sound '{arguments[0]}'. Please make sure the sound exists in the !sounds list."); } } else if (command == "!sounds") { return(GetSoundToolTip()); } return(null); }
public virtual TItem[] GetChosen(ItemCheckEventArgs e) { if (CheckedListBox == null) { return(new TItem[0]); } List <TItem> listChosen = new List <TItem>(); for (int i = 0; i < CheckedListBox.Items.Count; i++) { TItem item; bool checkItem = CheckedListBox.GetItemChecked(i); // If event refers to this item, then use the check state in the event. if (e != null && e.Index == i) { checkItem = (e.NewValue == CheckState.Checked); } if (checkItem && List.TryGetValue(CheckedListBox.Items[i].ToString(), out item)) { listChosen.Add(item); } } return(listChosen.ToArray()); }
private string GetIdString(DataTable dt, CheckedListBox clb, string colID) { try { string testIdString = string.Empty; for (int i = 0; i < clb.Items.Count; i++) { if (clb.GetItemChecked(i)) { testIdString += dt.Rows[i][colID] + ","; } } if (testIdString.EndsWith(",")) { testIdString = testIdString.Remove(testIdString.Length - 1); } if (testIdString == string.Empty) { return("-3"); } else { return(testIdString); } } catch (Exception) { throw; } }
private void clstComboList_ItemCheck(object sender, ItemCheckEventArgs e) { OnItemCheck(e); if (e.CurrentValue != CheckState.Indeterminate) { string str = ""; int count = _CheckListBox.Items.Count; for (int i = 0; i < count; i++) { if (_OnlyItemChecked) { if (i != e.Index) { _CheckListBox.SetItemChecked(i, false); } } bool b = _CheckListBox.GetItemChecked(i); if ((b && i != e.Index) || (!b && i == e.Index)) { str += "{" + _CheckListBox.Items[i].ToString() + "}"; } } _TxtInputValue.Text = str; } }
/// <summary> /// Returns all checked items as ColumnDetails list. /// </summary> /// <param name="sender"></param> /// <returns>List of ColumnDetails</returns> /// <remarks>recommended to check the count, if 0 no items checked.</remarks> public static List <SqlColumn> CheckedIColumnDetailsList(this CheckedListBox sender) { var result = from column in sender.Items.OfType <SqlColumn>() .Where((item, index) => sender.GetItemChecked(index)) select column; return(result.ToList()); }
public void SelectAllorNone(CheckedListBox CL) { int SelectedNum = 0; for (int i = 0; i < CL.Items.Count; i++) { if (CL.GetItemChecked(i)) { SelectedNum++; } } if (SelectedNum == CL.Items.Count) { for (int i = 0; i < CL.Items.Count; i++) { CL.SetItemChecked(i, false); } } else { for (int i = 0; i < CL.Items.Count; i++) { CL.SetItemChecked(i, true); } } }
public static void ApplyTags(string key, CheckedListBox box, ItemCheckEventArgs e) { if (Resetting > 0) { return; } object[] vals = new object[box.CheckedItems.Count + (e.NewValue == CheckState.Checked ? 1 : -1)]; int d = 0; for (int c = 0; c < box.Items.Count; c++) { if (box.GetItemChecked(c)) { if (c != e.Index || e.NewValue != CheckState.Unchecked) { vals[d] = box.Items[c].ToString(); d++; } } } if (e.NewValue == CheckState.Checked) { vals[d] = box.Items[e.Index].ToString(); } if (key.Equals("material") && vals.Length == 1) { ApplyValue(key, vals[0], ((JsonFormTag)box.Tag).mandatory); } else { ApplyValue(key, vals, ((JsonFormTag)box.Tag).mandatory); } }
public void GetItemCheckedExceptionTest() { CheckedListBox mychklistbox = new CheckedListBox(); mychklistbox.Items.Add("test1", true); Assert.AreEqual(true, mychklistbox.GetItemChecked(1), "#13"); }
/// <override></override> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null && context.Instance is Shape) { Shape shape = (Shape)context.Instance; using (CheckedListBox listBox = new CheckedListBox()) { listBox.BorderStyle = BorderStyle.None; listBox.IntegralHeight = false; listBox.Items.Clear(); // Add existing layers and check shape's layers foreach (Layer l in shape.Diagram.Layers) { int idx = listBox.Items.Count; listBox.Items.Insert(idx, l); listBox.SetItemChecked(idx, ((shape.Layers & l.Id) != 0)); } edSvc.DropDownControl(listBox); LayerIds shapeLayers = LayerIds.None; for (int i = listBox.Items.Count - 1; i >= 0; --i) { if (listBox.GetItemChecked(i)) shapeLayers |= ((Layer)listBox.Items[i]).Id; } shape.Diagram.RemoveShapeFromLayers(shape, LayerIds.All); shape.Diagram.AddShapeToLayers(shape, shapeLayers); value = shapeLayers; } } } return value; }
private void butLuu_Click(object sender, System.EventArgs e) { string s_Phongthuchiencls = ""; if (!kiemtra()) { return; } for (int i = 0; i < chkloaivp.Items.Count; i++) { if (chkloaivp.GetItemChecked(i)) { s_Phongthuchiencls += ds_loaivp.Tables[0].Rows[i]["id"].ToString().Trim() + ","; } } if (s_Phongthuchiencls != "") { s_Phongthuchiencls = s_Phongthuchiencls.Substring(0, s_Phongthuchiencls.Length - 1); } if (!m.upd_dmphongthuchiencls(i_id, txtMa.Text.Trim(), txtten.Text.Trim(), s_Phongthuchiencls, int.Parse(cbChinhanh.SelectedValue.ToString()), cbLoai.SelectedIndex)) { MessageBox.Show(lan.Change_language_MessageText("Không cập nhật thông tin !")); return; } ena_text(false); load_grid(); ena_object(false); }
private void listView1_SelectedValue(object sender, EventArgs e) { if (DropState == DropDownState.Dropping || DropState == DropDownState.Closing) { return; } string text = ""; IEnumerator checkedEnum = fCheckedListBox.CheckedIndices.GetEnumerator(); while (checkedEnum.MoveNext()) { int idx = (int)checkedEnum.Current; if (fCheckedListBox.GetItemChecked(idx)) { text += fCheckedListBox.Items[idx] + ";"; } } Text = text; //CloseDropDown(); if (OptionsChanged != null) { OptionsChanged(null, null); } }