private void undoList_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { int index = this.undoList.IndexFromPoint(e.X, e.Y); if (index != -1) { ListBox.SelectedIndexCollection selectedIndices = this.undoList.SelectedIndices; for (int i = index; i >= 0; i--) { if (!selectedIndices.Contains(i)) { this.undoList.SetSelected(i, true); } } for (int i = index + 1; i < this.undoList.Items.Count; i++) { if (selectedIndices.Contains(i)) { this.undoList.SetSelected(i, false); } } index++; this.undoLabel.Text = "Undo " + index.ToString() + " Actions."; } }
/// <summary> /// Returns a list with values "true" if the items are selected and false if the items are not selected. /// </summary> /// <param name="itemsCount">Number of items the have</param> /// <param name="selectedIndices">List with selected indexes number</param> /// <returns></returns> private static List <bool> GetListboxItemsSelection(int itemsCount, ListBox.SelectedIndexCollection selectedIndices) { var selectionItems = new List <bool>(itemsCount); for (var i = 0; i < itemsCount; i++) { selectionItems.Add(selectedIndices.Contains(i)); } return(selectionItems); }
private void listBox3_DragOver(object sender, DragEventArgs e) { ListBox.SelectedIndexCollection data = (ListBox.SelectedIndexCollection)e.Data.GetData(typeof(ListBox.SelectedIndexCollection)); if (data.Contains(0)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } }
private void Borrar_Click(object sender, EventArgs e) { ListBox.SelectedIndexCollection indices = listBox1.SelectedIndices; for (int i = listBox1.Items.Count - 1; i >= 0; i--) { if (indices.Contains(i)) { listBox1.Items.RemoveAt(i); sFrikis.RemoveAt(i); } } }
private void m_listbox_SelectedIndexChanged(object sender, EventArgs e) { if (m_bInEvent) { return; } m_bInSelect = true; MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc(); // Select what got selected ListBox.SelectedIndexCollection selected = m_listbox.SelectedIndices; // Select what got selected int i = 0; for (i = 0; i < selected.Count; i++) { int index = selected[i]; if (!m_selected.Contains(index)) { Guid guid = new Guid(m_listbox.Items[index].ToString()); MRhinoObject obj = doc.LookupObject(guid); if (obj != null && obj.IsSelectable()) { obj.Select(true); } } } // Unselect what got unselected for (i = 0; i < m_selected.Count; i++) { int index = m_selected[i]; if (!selected.Contains(index)) { Guid guid = new Guid(m_listbox.Items[index].ToString()); MRhinoObject obj = doc.LookupObject(guid); if (obj != null) { obj.Select(false); } } } SaveSelectedIndices(); doc.Redraw(); m_bInSelect = false; }
private void listBox3_DragDrop(object sender, DragEventArgs e) { ListBox.SelectedIndexCollection data = (ListBox.SelectedIndexCollection)e.Data.GetData(typeof(ListBox.SelectedIndexCollection)); if (data.Contains(0)) { int count = data.Count; for (int i = 1; i <= count; ++i) { listBox3.Items.Add(listBox1.Items[0]); listBox1.Items.RemoveAt(0); } setChanged(true); } }
private void TrackSelectionChange(ListBox lb, List <int> selection) { try { ListBox.SelectedIndexCollection sic = lb.SelectedIndices; foreach (int index in sic) { if (!selection.Contains(index)) { selection.Add(index); } } foreach (int index in new List <int>(selection)) { if (!sic.Contains(index)) { selection.Remove(index); } } if (lb.Name != "listBoxSchueler") { aktiveKlasse = klasses[listBox1_selection[listBox1_selection.Count - 1]].NameAtlantis; SchuelerDerAktivenKlasse = (from s in schuelers where !s.Nachname.Contains(s.Klasse) where s.Vorname.Length > 1 where s.Klasse == aktiveKlasse select s).ToList(); listBoxSchueler.DataSource = (from s in SchuelerDerAktivenKlasse select s.Nachname + ", " + s.Vorname).ToList(); for (int i = 0; i < SchuelerDerAktivenKlasse.Count; i++) { if ((from g in gewählteSchüler where g.Nachname == SchuelerDerAktivenKlasse[i].Nachname && g.Vorname == SchuelerDerAktivenKlasse[i].Vorname && g.Klasse == SchuelerDerAktivenKlasse[0].Klasse select g).Any()) { listBoxSchueler.SetSelected(i, true); } else { listBoxSchueler.SetSelected(0, false); } } } } catch (Exception ex) { lblStartup.Text = ex.Message; } }
private void btnDown_Click(object sender, EventArgs e) { ListBox.SelectedIndexCollection col = this.lbSequences.SelectedIndices; for (int i = this.lbSequences.Items.Count - 1; i >= 0; i--) { if ((col.Contains(i)) && (i < this.lbSequences.Items.Count - 1)) { object item = this.lbSequences.Items[i]; this.lbSequences.Items.RemoveAt(i); this.lbSequences.Items.Insert(i + 1, item); this.lbSequences.SetSelected(i + 1, true); } } }
private void btnUp_Click(object sender, EventArgs e) { // Get the collection of selected indexes in the ListBox. ListBox.SelectedIndexCollection sic = this.lbSequences.SelectedIndices; // Loop through the ListBox. for (int i = 0; i <= this.lbSequences.Items.Count - 1; i++) { // If this index is in the collection. if ((sic.Contains(i)) && (i > 0)) { // Move the item one index upward. object item = this.lbSequences.Items[i]; this.lbSequences.Items.RemoveAt(i); this.lbSequences.Items.Insert(i - 1, item); this.lbSequences.SetSelected(i - 1, true); } } }
private void TrackSelectionChange(ListBox lb, List <int> selection) { ListBox.SelectedIndexCollection sic = lb.SelectedIndices; foreach (int index in sic) { if (!selection.Contains(index)) { selection.Add(index); } } foreach (int index in new List <int>(selection)) { if (!sic.Contains(index)) { selection.Remove(index); } } }
private void down_Click(object sender, EventArgs e) { listBox1.BeginUpdate(); listBox2.BeginUpdate(); ListBox.SelectedIndexCollection col = this.listBox1.SelectedIndices; for (int i = this.listBox1.Items.Count; i >= 0; i--) { if ((col.Contains(i)) && (i < this.listBox1.Items.Count - 1)) { object o = this.listBox1.Items[i]; this.listBox1.Items.RemoveAt(i); this.listBox1.Items.Insert(i + 1, o); this.listBox1.SetSelected(i + 1, true); object p = this.listBox2.Items[i]; this.listBox2.Items.RemoveAt(i); this.listBox2.Items.Insert(i + 1, p); this.listBox2.SetSelected(i + 1, true); } } listBox1.EndUpdate(); listBox2.EndUpdate(); }