private void ListBoxPartitions_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && listBoxPartitions.SelectedItems.Count > 0) { int mouseIndex = listBoxPartitions.IndexFromPoint(e.Location); if (mouseIndex > -1) { ListBox.SelectedObjectCollection x = new ListBox.SelectedObjectCollection(listBoxPartitions); if (Control.ModifierKeys == Keys.Shift) { int i1 = Math.Min(listBoxPartitions.SelectedIndex, mouseIndex); int i2 = Math.Max(listBoxPartitions.SelectedIndex, mouseIndex); for (int i = i1; i <= i2; ++i) { x.Add(listBoxPartitions.Items[i]); } } else { x = listBoxPartitions.SelectedItems; } var dropResult = DoDragDrop(x, DragDropEffects.Move); } } }
public void ListBoxSelectedObjectCollection_IListClear_Invoke_ThrowsNotSupportedException() { using var owner = new ListBox(); IList collection = new ListBox.SelectedObjectCollection(owner); Assert.Throws <NotSupportedException>(() => collection.Clear()); }
private void ButtonAddUser_Click(object sender, EventArgs e) { if (ListBoxSource.SelectedItems.Count != 0) { List <ListBoxItem> listBoxItemList = new List <ListBoxItem>(); ListBox.SelectedObjectCollection collection = ListBoxSource.SelectedItems; if (!multipleSelect && ListBoxSelected.Items.Count > 0) { MessageBox.Show("사용자선택은 1명만 가능합니다.", "선택초과", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (ListBoxItem member in collection) { if (ListBox.NoMatches != ListBoxSelected.FindStringExact(member.Text)) { MessageBox.Show("이미 선택된 사용자 입니다.", "중복선택", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { ListBoxSelected.Items.Add(member); listBoxItemList.Add(member); } } foreach (ListBoxItem obj in listBoxItemList) { ListBoxSource.Items.Remove(obj); } } }
private void button2_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection c = listBox1.SelectedItems; ArrayList para = new ArrayList(c); filterSemester(para); }
public void ListBoxSelectedObjectCollection_IListItem_Set_ThrowsNotSupportedException(int index, object value) { using var owner = new ListBox(); IList collection = new ListBox.SelectedObjectCollection(owner); Assert.Throws <NotSupportedException>(() => collection[index] = value); }
private void toolStripMenuItemCopiar_Click(object sender, EventArgs e) { if (currentListBox == null) { return; } ListBox.SelectedObjectCollection items = null; var str = new StringBuilder(); if (currentListBox == lstBoxCodigoDeReferencia) { items = lstBoxCodigoDeReferencia.SelectedItems; } else if (currentListBox == lstBoxOutrosCodigos) { items = lstBoxOutrosCodigos.SelectedItems; } if (items == null) { return; } foreach (var item in items) { str.AppendLine(item.ToString()); } Clipboard.SetText(str.ToString()); currentListBox = null; }
private void karakterTorlesButton_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection kijeloltElem = new ListBox.SelectedObjectCollection(harcosokListBox); kijeloltElem = harcosokListBox.SelectedItems; int harcosId = ((Harcos)harcosokListBox.SelectedItem).Id; bool sikerult = false; sql.CommandText = "DELETE FROM `harcosok` WHERE `harcosok`.`id` = '" + harcosId + "' "; using (MySqlDataReader dr = sql.ExecuteReader()) { while (dr.Read()) { if (kijeloltElem.Count != -1) { for (int i = kijeloltElem.Count - 1; i >= 0; i--) { harcosokListBox.Items.Remove(kijeloltElem[i]); sikerult = true; } } } if (sikerult == true) { MessageBox.Show("Sikeresen kitörölted a kijelölt elemet."); } else { MessageBox.Show("Sikertelenül törölted ki az elemet."); } } }
private void buttonDoCycle_Click(object sender, EventArgs e) { if (listBoxScript.SelectedItem != null) { if (int.TryParse(textBoxDoCycle.Text, out var count)) { if (!checkBoxSelectionMode.Checked) { for (var i = 0; i < count; i++) { var index = listBoxScript.Items.IndexOf(listBoxScript.SelectedItem); buttonAddToScript_Click(sender, e); listBoxScript.SelectedItem = listBoxScript.Items[index + 1]; } } else { var sc = new ListBox.SelectedObjectCollection(listBoxScript); if (!CheckCollection(sc) || count <= 0) { return; } var ls = new List <string>(); var i = 0; while (i <= lastIndex) { ls.Add(listBoxScript.Items[i].ToString()); i++; } for (i = 0; i < count - 1; i++) { foreach (var s in sc) { ls.Add(s.ToString()); } } i = lastIndex + 1; while (i < listBoxScript.Items.Count) { ls.Add(listBoxScript.Items[i].ToString()); i++; } listBoxScript.Items.Clear(); foreach (var s in ls) { listBoxScript.Items.Add(s); } ls.Clear(); } } else { MessageBox.Show("Не задано n.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Нет выделенных элементов.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private bool CheckCollection(ListBox.SelectedObjectCollection sysCol) { var res = true; lastIndex = -1; var i = 0; while (i < listBoxScript.Items.Count && res) { if (sysCol.Contains(listBoxScript.Items[i])) { if (lastIndex == -1) { lastIndex = i; } else { if (i != lastIndex + 1) { res = false; } lastIndex = i; } } i++; } return(res); }
private void buttonRemove_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection currentSelectedItems = listBoxFiles.SelectedItems; int selectedItemsCount = currentSelectedItems.Count; if (selectedItemsCount < 1) { return; } var selectedItems = new object[selectedItemsCount]; try { currentSelectedItems.CopyTo(selectedItems, 0); } catch { return; } listBoxFiles.BeginUpdate(); foreach (object item in selectedItems) { listBoxFiles.Items.Remove(item); } listBoxFiles.EndUpdate(); }
private void btnBuy_Click(object sender, EventArgs e) { cash = Convert.ToInt32(textBoxCash.Text); int buy = Convert.ToInt32(tbTotal.Text); { //tbwarehouse.Text = Convert.ToString(quanty); if ((cash >= buy)) { cash -= buy; textBoxCash.Text = Convert.ToString(cash); selectedItems = listBoxBuy.SelectedItems; for (int j = 0; j < selectedItems.Count; j++) { listBoxSell.Items.Add(selectedItems[j]); listBoxBuy.Items.Add(selectedItems[j]); tbwarehouse.Text = Convert.ToString(quanty); } } else { MessageBox.Show("Not enough money!"); } } }
private void recipientList_KeyDown(object sender, KeyEventArgs e) { string mbmessage, mbcaption; MessageBoxButtons mbbuttons; DialogResult result; // If delete key is pressed, either delete // selected item(s) or show message box if (e.KeyCode == Keys.Delete) { ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(recipientList); selectedItems = recipientList.SelectedItems; if (recipientList.SelectedIndex != -1) { for (int i = selectedItems.Count - 1; i >= 0; i--) { recipientList.Items.Remove(selectedItems[i]); } } else { mbmessage = "Please select an item"; mbcaption = "Information"; mbbuttons = MessageBoxButtons.OK; result = MessageBox.Show(mbmessage, mbcaption, mbbuttons, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } e.Handled = true; } }
private void lsbElement_SelectedIndexChanged(object sender, EventArgs e) { ListBox.SelectedObjectCollection selectedItems = lsbElement.SelectedItems; int selectedIndex = lsbElement.SelectedIndex; if (lsbElement.SelectedIndex != -1) { //for (int i = selectedIndex; i < selectedItems.Count; i++) //{ // lines[i].IsSelected = true; //} for (int i = 0; i < lsbElement.Items.Count; i++) { if (i >= selectedIndex && i < selectedIndex + selectedItems.Count) { shapes[i].IsSelected = true; } else { shapes[i].IsSelected = false; } } pnPaint.Invalidate(); this.proGrid.SelectedObjects = shapes.Where(x => x.IsSelected).ToArray(); } }
private void RemoveDevicesUC_Remove_btn_Click(object sender, EventArgs e) { //Do all the calls for removing selected devices based on selected items in DeviceList_lbl. //DeviceList_lb.SelectedItems //GetCurrentDeviceNameList_GUI(char[] path); //Calculate namesToRemove. ListBox.SelectedObjectCollection selectedNames = DeviceList_lb.SelectedItems; //foreach (string x in selectedNames) //{ // MessageBox.Show(x); //} string[] namesToRemove = SOCtoStringArray(selectedNames); string namesToRemoveString = ELM_GUI.stringArrayToString(namesToRemove); //Calculate output path. string outputPath = "C:\\Users\\Mehdy Faik\\AppData\\Roaming\\SPB_16.6\\eagle\\Library_Holder\\General_Passives_Test1.lbr"; //Call. IntPtr val_PTR = ELM_GUI.RemoveDevices_GUI(ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.inputPath), ELM_GUI.stringToCharArray(namesToRemoveString), ELM_GUI.stringToCharArray(ELM_GUI.CurrentSession.outputPath) ); //Interpret. ELM_GUI.CurrentSession.ProcessIntPtrToStringArray(val_PTR); //Update namelist in device box. updateDeviceList(); }
private void RemoveButton_Click(object sender, EventArgs e) { String projectfile = ReadCurrentProjectFileName(); if (listBox1.SelectedIndex > 0) { ListBox.SelectedObjectCollection items = listBox1.SelectedItems; foreach (Object item in items) { if (File.Exists(item.ToString())) { File.Delete(item.ToString()); XmlDocument doc = new XmlDocument(); doc.Load(projectfile); XmlNodeList nodes = doc.GetElementsByTagName("OtherFile"); for (int i = 0; i < nodes.Count; i++) { XmlNode node = nodes[i]; if (node.InnerText == item.ToString()) { node.ParentNode.RemoveChild(node); } } doc.Save(projectfile); } } } this.Close(); }
public void DeleteCar(ListBox.SelectedObjectCollection rendsz) { MySqlTransaction trans = null; if (connection == null) { Init(); } try { trans = connection.BeginTransaction(); deleteCar.Transaction = trans; foreach (string rsz in rendsz) { deleteCar.Parameters[0].Value = rsz; deleteCar.ExecuteNonQuery(); } trans.Commit(); } catch (MySqlException) { trans.Rollback(); MessageBox.Show("Az adatbázis frissítése nem sikerült.", "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { trans = null; } }
/// <summary> /// Removes the task from the selection list and removes it from the Task selector list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RemoveTask_Click(object sender, EventArgs e) { //Removing selected item(s) from Current Tasks ListBox.SelectedObjectCollection currentItems = new ListBox.SelectedObjectCollection(SelectableTaskList); currentItems = SelectableTaskList.SelectedItems; if (SelectableTaskList.SelectedIndex != -1 && taskDisplayDropdown.SelectedIndex == 0) { currentTasks.RemoveAt(SelectableTaskList.SelectedIndex); SelectableTaskList.Items.RemoveAt(SelectableTaskList.SelectedIndex); } //Removing selected item(s) from Previous Tasks ListBox.SelectedObjectCollection previousItems = new ListBox.SelectedObjectCollection(SelectableTaskList); previousItems = SelectableTaskList.SelectedItems; if (SelectableTaskList.SelectedIndex != -1 && taskDisplayDropdown.SelectedIndex == 1) { previousTasks.RemoveAt(SelectableTaskList.SelectedIndex); SelectableTaskList.Items.RemoveAt(SelectableTaskList.SelectedIndex); } //Removing selected item(s) from Upcoming Tasks ListBox.SelectedObjectCollection upcomingItems = new ListBox.SelectedObjectCollection(SelectableTaskList); upcomingItems = SelectableTaskList.SelectedItems; if (SelectableTaskList.SelectedIndex != -1 && taskDisplayDropdown.SelectedIndex == 2) { upcomingTasks.RemoveAt(SelectableTaskList.SelectedIndex); SelectableTaskList.Items.RemoveAt(SelectableTaskList.SelectedIndex); } }
public double?toDoubleIfPossible(string s, ListBox.SelectedObjectCollection selectedFormats) { double?ret = null; List <IFormat> selectedIFormats = new List <IFormat>(); foreach (var f in selectedFormats) { selectedIFormats.Add(descriptionFormat[f.ToString()]); } StringBuilder sb = new StringBuilder(); foreach (var f in selectedIFormats) { sb.AppendLine(f.ToString()); } //MessageBox.Show(sb.ToString()); foreach (IFormat format in selectedIFormats) { if (format.isInThisFormat(s)) { ret = format.toDouble(s); break; } } return(ret); }
private void kepessegTorlesButton_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection kijeloltElem = new ListBox.SelectedObjectCollection(kepessegekListBox); kijeloltElem = kepessegekListBox.SelectedItems; int kepessegId = ((Kepesseg)kepessegekListBox.SelectedItem).Id; bool sikerult = false; sql.CommandText = "DELETE FROM `kepessegek` WHERE `kepessegek`.`id` = '" + kepessegId + "' "; using (MySqlDataReader dr = sql.ExecuteReader()) { while (dr.Read()) { if (kijeloltElem.Count != -1) { for (int i = kijeloltElem.Count - 1; i >= 0; i--) { kepessegekListBox.Items.Remove(kijeloltElem[i]); sikerult = true; } } if (sikerult = true) { MessageBox.Show("Sikeres képesség törlés"); } else { MessageBox.Show("Sikertelen képesség törlés"); } } } }
private void removeCategoryFromResourceButton_Click(object sender, System.EventArgs evt) { Resource resource = (Resource)resourcesList.SelectedItem; ListBox.SelectedObjectCollection categories = resourceCategoriesList.SelectedItems; if (resource == null || categories.Count == 0) { return; } // can't use an enumerator because we'll be removing categories from the list Category[] cats = new Category[categories.Count]; categories.CopyTo(cats, 0); for (int i = 0; i < cats.Length; i++) { Category cat = cats[i]; bool success = resourceDAO.RemoveResourceFromCategory(resource, cat.Name); if (success) { resourceCategoriesList.Items.Remove(cat); availableCategoriesList.Items.Add(cat); } else { Error("Could not remove resource from category."); } } }
//──────────────────────────────────────── /// <summary> /// 項目の削除 /// /// リストで選択されている項目を削除します。 /// </summary> /// <returns>削除した項目数。</returns> public List <object> RemoveSelectedItem() { List <object> list_RemovedItem = new List <object>(); ListBox.SelectedObjectCollection collection = this.listboxWrapper.SelectedItems; if (collection.Count < 1) { // リストボックスの項目が選択されていなかった場合は、メッセージボックスを出します。 MessageBox.Show(this.SMessage_SelectionPrompted); } else { // 逆回転します。前から削除すると、要素番号が前倒しにずれてくるので。 for (int nIndex = collection.Count - 1; 0 <= nIndex; nIndex--) { list_RemovedItem.Add(collection[nIndex]); this.listboxWrapper.Items.Remove(collection[nIndex]); } // 選択を解除します。 this.listboxWrapper.ClearSelected(); } return(list_RemovedItem); }
private void MoveListBoxItemsCheckOwner(ListBox source, ListBox destination) { Boolean ownerInGroup = false; ListBox.SelectedObjectCollection sourceItems = source.SelectedItems; for (int i = 0; i < source.SelectedItems.Count; i++) { if (source.SelectedItems[i].ToString() == ownerName) { MessageBox.Show("The creator of the group cannot be removed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ownerInGroup = true; break; } else { destination.Items.Add(source.SelectedItems[i].ToString()); } } if (!ownerInGroup) { while (source.SelectedItems.Count > 0) { source.Items.Remove(source.SelectedItems[0]); } } }
public void ListBoxSelectedObjectCollection_IListRemoveAt_Invoke_ThrowsNotSupportedException(int index) { using var owner = new ListBox(); IList collection = new ListBox.SelectedObjectCollection(owner); Assert.Throws <NotSupportedException>(() => collection.RemoveAt(index)); }
public void DeleteMeeting(ListBox.SelectedObjectCollection MeetingsToDelete) { foreach (Meeting m in MeetingsToDelete) { db.DeleteMeeting(m); } }
public void ListBoxSelectedObjectCollection_IListAdd_Invoke_ThrowsNotSupportedException(object value) { using var owner = new ListBox(); IList collection = new ListBox.SelectedObjectCollection(owner); Assert.Throws <NotSupportedException>(() => collection.Add(value)); }
private void btnMinus_Click(object sender, EventArgs e) { ListBox lsb = lsbFields; ComboBox cmb = cmbFields; ListBox.SelectedObjectCollection s = lsb.SelectedItems; int cnt = s.Count; List <string> rLst = new List <string>(); for (int i = 0; i < cnt; i++) { string txt = s[i].ToString(); rLst.Add(txt); if (txt != null && txt != "") { if (!cmb.Items.Contains(txt)) { cmb.Items.Add(txt); } } } foreach (string r in rLst) { lsb.Items.Remove(r); } }
private XmlDocument AddListBoxItems(XmlDocument oXmlDocument, XmlNode oXMLMainNode, string szControlType, string szName, ListBox.SelectedObjectCollection oItems) { XmlNode oXMLNode; XmlNode oXMLItemNode; XmlAttribute oXmlAttribute; oXMLNode = oXmlDocument.CreateNode(XmlNodeType.Element, "Control", string.Empty); oXMLMainNode.AppendChild(oXMLNode); oXmlAttribute = oXmlDocument.CreateAttribute("type"); oXmlAttribute.Value = szControlType; oXMLNode.Attributes.Append(oXmlAttribute); oXmlAttribute = oXmlDocument.CreateAttribute("name"); oXmlAttribute.Value = szName; oXMLNode.Attributes.Append(oXmlAttribute); foreach (ListItem oItem in oItems) { oXMLItemNode = oXmlDocument.CreateNode(XmlNodeType.Element, "value", string.Empty); oXMLItemNode.InnerText = oItem.Value.ToString(); oXMLNode.AppendChild(oXMLItemNode); } return(oXmlDocument); }
private bool LoadEspetaculos(Espetaculos es) { ProjetoCircoEntities db = new ProjetoCircoEntities(); es.NMEspetaculo = txtNMEspetaculo.Text; es.DTEspetaculo = txtDTHR.Text; db.Espetaculos.Add(es); db.SaveChanges(); ListBox.SelectedObjectCollection listaCol = lstCol.SelectedItems; ListBox.SelectedObjectCollection listLocal = lstLocal.SelectedItems; ListBox.SelectedObjectCollection listArtista = lstArtistas.SelectedItems; ListBox.SelectedObjectCollection listaPec = lstPec.SelectedItems; try { foreach (Artistas art in listArtista) { Pagos f = new Pagos { IDArtista = art.Id, IDEspetaculo = es.IDEspetaculo, Pago = null }; db.Pagos.Add(f); } db.SaveChanges(); foreach (Local loc in listLocal) { LocalEspetaculo e = new LocalEspetaculo { IDEspetaculo = es.IDEspetaculo, IDLocal = loc.IDLocal }; db.LocalEspetaculo.Add(e); } db.SaveChanges(); foreach (Peças pe in listaPec) { Figurino f = new Figurino { IDPec = pe.CDPeças, IDEspetaculo = es.IDEspetaculo }; db.Figurino.Add(f); } db.SaveChanges(); }catch (Exception ex) { MessageBox.Show("Erro ao salvar :( " + ex.Message); return(false); } return(true); }
private void clbVisibilityToUsers_ItemCheck(object sender, ItemCheckEventArgs e) { ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(clbVisibilityToUsers); selectedItems = clbVisibilityToUsers.SelectedItems; if (clbVisibilityToUsers.SelectedIndex != -1) { for (int i = selectedItems.Count - 1; i >= 0; i--) { var userright = selectedItems[i] as SINerUserRight; if (userright != null) { if (e.NewValue == CheckState.Checked) { userright.CanEdit = true; } else { userright.CanEdit = false; } } } } else { MessageBox.Show("No email selected!"); } }
//Event που ενεργοποιείται κατα το πάτημα του κουμπιού Remove private void btn_Remove_Click(object sender, EventArgs e) { try { //Φτιαξε μια νεα μεταβλητή τύπου ListBox.SelectedObjectCollection που θα κρατάει τα στοιχεία που έχει επιλέξει //ο χρήστης απο το ListBox ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(lstb_CurrentAlarms); selectedItems = lstb_CurrentAlarms.SelectedItems; //Αν έχει επιλεγεί στοιχεία από το Listbox if (lstb_CurrentAlarms.SelectedIndex != -1) { //αφαίρεσε τα στοιχεία απο το ListBox και απο την λίστα ξυπνητιριών for (int i = selectedItems.Count - 1; i >= 0; i--) { lstb_CurrentAlarms.Items.Remove(selectedItems[i]); AlarmObj.Remove(AlarmObj[i]); //Ορισε την τιμή του μετρητή ίση με αυτή του πλήθους των στοιχείων της λίστας alarmsCount = AlarmObj.Count; } } else { MessageBox.Show("fail"); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }