void listBox_DragDrop(object sender, DragEventArgs e) { ListBox listBox = (ListBox)sender; foreach (Object item in usersListBox.SelectedItems) { listBox.Items.Add((string)item); } ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(usersListBox); selectedItems = usersListBox.SelectedItems; for (int i = selectedItems.Count - 1; i >= 0; i--) usersListBox.Items.Remove(selectedItems[i]); }
private void btn_deleteSel_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(lbx_camList); selectedItems = lbx_camList.SelectedItems; if (lbx_camList.SelectedIndex != -1) { for (int i = selectedItems.Count - 1; i >= 0; i--) lbx_camList.Items.Remove(selectedItems[i]); } else MessageBox.Show("Select the Camera you want to delete and press the button","Camera not selected"); }
private void lbx_camList_SelectedIndexChanged(object sender, EventArgs e) { ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(lbx_camList); selectedItems = lbx_camList.SelectedItems; if (lbx_camList.SelectedIndex != -1) { btn_deleteSel.Enabled = true; btn_getSelected.Enabled = true; string selCam = lbx_camList.SelectedItem.ToString(); string[] selectedCam = selCam.Split(new string[] { " " }, StringSplitOptions.None); camName = selectedCam[0]; // ime kamere camURL = selectedCam[1]; // URL kamere camUserName = selectedCam[2]; // Username camPassword = selectedCam[3]; // Password za kameru } }
private void deleteSelectedToolStripMenuItem_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(listBoxAddress); selectedItems = listBoxAddress.SelectedItems; if (listBoxAddress.SelectedIndex != -1) { for (int i = selectedItems.Count - 1; i >= 0; i--) { //IPAddress address = IPAddress.Parse(selectedItems[i].ToString()); network.Remove(selectedItems[i].ToString()); listBoxAddress.Items.Remove(selectedItems[i]); } } else MessageBox.Show("Not selected item's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); }
private void listBox_MouseDown(object sender, MouseEventArgs e) { // Save the selected items for use in other functions that inexplicably don't have access to this _listBoxSelectedItems = ((ListBox)sender).SelectedItems; // Only do this if the right mouse button is clicked on the control if (e.Button != MouseButtons.Right) return; // Get the index of the item clicked upon from the mouse position var index = ((ListBox) sender).IndexFromPoint((e.Location)); // If the index is not a valid item in the list, remove the context menu // so it doesn't show up on an empty space, then return if (index == ListBox.NoMatches) { ((ListBox) sender).ContextMenuStrip = null; return; } // The index clicked upon was valid, so we need to add the context menu // back to the form so that it returns the proper owner later. ((ListBox)sender).ContextMenuStrip = contextMenuListBox; // Go ahead and add the currently moused over index to the selected items ((ListBox)sender).SelectedIndices.Add(index); // Show the context menu where the mouse cursor is positioned (why is this not default?) contextMenuListBox.Show(Cursor.Position); }
/// <summary> /// Removes selected items from list. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonRemove_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection Obj = new ListBox.SelectedObjectCollection(listBoxKeyFiles); for (int i = Obj.Count - 1; i >= 0; i--) { listBoxKeyFiles.Items.Remove(Obj[i]); } if (listBoxKeyFiles.SelectedItem == null) buttonRemove.Enabled = false; }
private void button3_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection seletedItems = new ListBox.SelectedObjectCollection(listBox1); seletedItems = listBox1.SelectedItems; int range = seletedItems.Count; bool find = false; string dPath = string.Empty; //일반데이터 삭제시 if(clicked == 0) { for(int i = 0; i < range; i++) { for (int j = 0; j < temp_route_data.Count; j++) { if (temp_route_data[j].tag.CompareTo(seletedItems[0]) == 0) { under_bar_index.Clear(); find = false; //해당 태그와 같은 파일 이름을 먼저 찾고. for (int k = 0; k < filenames.Length; k++) { for (int h = 0; h < filenames[k].Length; h++) { if (filenames[k][h].CompareTo('_') == 0) { under_bar_index.Add(h); } } //peer // user 구분 string div_temp = filenames[k].Substring(under_bar_index[0] + 1, (under_bar_index[1] - under_bar_index[0]) - 1); string temp_scenario_tag = filenames[k][0].ToString(); string temp_scenario_name = filenames[k].Substring(under_bar_index[2] + 1, (under_bar_index[3] - under_bar_index[2]) - 1); string temp_devicie_id = filenames[k].Substring(under_bar_index[3] + 1, (under_bar_index[4] - under_bar_index[3]) - 1); string temp_project_name = filenames[k].Substring(under_bar_index[1] + 1, (under_bar_index[2] - under_bar_index[1]) - 1); if ((temp_scenario_tag.CompareTo(temp_route_data[j].tag.ToString())) == 0 && (temp_scenario_name.CompareTo(temp_route_data[j].scenario_name)) == 0 && (temp_project_name.CompareTo(project_name) == 0)) { dPath = @"C:\Users\" + Environment.UserName + "\\Nudge\\" + filenames[k]; //dPath = @"C:\Users\" + Environment.UserName + "\\Nudge\\test.txt"; find = true; break; } } //여기서 삭제 하고 나가기 if (find == true) { listBox1.Items.Remove(seletedItems[0]); temp_route_data.RemoveAt(j); MessageBox.Show("삭제할 데이터 : " + dPath); //File.Delete(dPath); break; } } } } RefreshRoute(); } else { for (int i = 0; i < range; i++) { for (int j = 0; j < temp_survey_data.Count; j++) { if (temp_survey_data[j].tag.CompareTo(seletedItems[0]) == 0) { under_bar_index.Clear(); find = false; //해당 태그와 같은 파일 이름을 먼저 찾고. for (int k = 0; k < filenames.Length; k++) { for (int h = 0; h < filenames[k].Length; h++) { if (filenames[k][h].CompareTo('_') == 0) { under_bar_index.Add(h); } } //peer // user 구분 string div_temp = filenames[k].Substring(under_bar_index[0] + 1, (under_bar_index[1] - under_bar_index[0]) - 1); string temp_scenario_tag = filenames[k][0].ToString(); string temp_scenario_name = filenames[k].Substring(under_bar_index[2] + 1, (under_bar_index[3] - under_bar_index[2]) - 1); string temp_devicie_id = filenames[k].Substring(under_bar_index[3] + 1, (under_bar_index[4] - under_bar_index[3]) - 1); string temp_project_name = filenames[k].Substring(under_bar_index[1] + 1, (under_bar_index[2] - under_bar_index[1]) - 1); if ((temp_scenario_tag.CompareTo(temp_survey_data[j].tag.ToString())) == 0 && (temp_scenario_name.CompareTo(temp_survey_data[j].scenario_name)) == 0 && (temp_project_name.CompareTo(project_name) == 0)) { dPath = @"C:\Users\" + Environment.UserName + "\\Nudge\\" + filenames[k]; //dPath = @"C:\Users\" + Environment.UserName + "\\Nudge\\test.txt"; find = true; break; } } //여기서 삭제 하고 나가기 if (find == true) { listBox1.Items.Remove(seletedItems[0]); temp_survey_data.RemoveAt(j); MessageBox.Show("삭제할 데이터 : " + dPath); //File.Delete(dPath); break; } } } } RefreshSurvey(); } }
private void etiquetarBTN_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection usuarios = new ListBox.SelectedObjectCollection(listAmigos); usuarios = listAmigos.SelectedItems; if (listAmigos.SelectedIndex != -1) { foreach (Usuario usu in usuarios) { if(!listUsuariosEtiquetados.Items.Contains(usu)){ listUsuariosEtiquetados.Items.Add(usu); } } } else MessageBox.Show("Debe seleccionar un usuario"); }
private void loadItemValues() { //Klassen wählen //serialized String this.item_classes.SelectedIndices.Clear(); if (item.ItemTemplate.Rows[0]["AllowedClasses"] != DBNull.Value) { string classes = (string)item.ItemTemplate.Rows[0]["AllowedClasses"]; //MessageBox.Show("classes: " + classes); string[] classes_split = classes.Split(Convert.ToChar(";")); ListBox.SelectedObjectCollection selectedClasses = new ListBox.SelectedObjectCollection(item_classes); for (int i = 0; i < this.item_classes.Items.Count; i++) { DataRowView row = (DataRowView)this.item_classes.Items[i]; for (int n = 0; n < classes_split.Length; n++) { //MessageBox.Show("vergleiche " + classes_split[n] + " mit " + row.Row["id"]); if (classes_split[n] == row.Row["id"].ToString()) { item_classes.SetSelected(i, true); //MessageBox.Show("selektiere " + classes_split[n]); } } } } //Stats categorien laden und Wert selektieren for (int i = 1; i <= 11; i++) { object bonusTypeObj; int bonusType; if (i == 11) bonusTypeObj = this.item.ItemTemplate.Rows[0]["ExtraBonusType"]; else bonusTypeObj = this.item.ItemTemplate.Rows[0]["Bonus" + i.ToString() + "Type"]; if (bonusTypeObj.ToString() != "") { bonusType = (int)bonusTypeObj; DataRow cat = this.baseXMLData.Tables["bonus"].Rows.Find(bonusType); ComboBox control = (ComboBox)this.Controls.Find("effectCat" + (i), true)[0]; control.SelectedValue = cat["category"]; ComboBox box = (ComboBox)this.Controls.Find("item_effect" + (i), true)[0]; box.SelectedValue = cat["id"]; } else { ComboBox control = (ComboBox)this.Controls.Find("effectCat" + (i), true)[0]; control.SelectedIndex = 0; } } getLootTemplatesOfItem(); }
private void usersListBox_DragDrop(object sender, DragEventArgs e) { try { foreach (Object item in selectedListBox.SelectedItems) { string itemValue = (string)item; if (!itemValue.Contains("Points:") && !itemValue.Contains("Group:")) usersListBox.Items.Add((string)item); } ListBox.SelectedObjectCollection selectedItems = new ListBox.SelectedObjectCollection(selectedListBox); selectedItems = selectedListBox.SelectedItems; for (int i = selectedItems.Count - 1; i >= 0; i--) { string itemValue = (string)selectedItems[i]; if (!itemValue.Contains("Points:") && !itemValue.Contains("Group:")) selectedListBox.Items.Remove(selectedItems[i]); } } catch { } }
private void button5_Click(object sender, EventArgs e) { ListBox.SelectedIndexCollection col = new ListBox.SelectedIndexCollection(listBox1); ListBox.SelectedObjectCollection col2 = new ListBox.SelectedObjectCollection(listBox1); col = listBox1.SelectedIndices; col2 = listBox1.SelectedItems; string s = ""; foreach (object obj in col2) { s += obj.ToString(); } if (col.Count == 2 && !s.Contains(" E ")) { listBox1.Items.Insert(col[0], col2[0].ToString() + " E " + col2[1].ToString()); listBox1.Items.RemoveAt(col[0]); listBox1.Items.RemoveAt(col[0]); } else { MessageBox.Show("Seleccione dois Filtros Únicos!"); } listBox1.ClearSelected(); }
private void button1_Click(object sender, EventArgs e) { ListBox.SelectedObjectCollection fotos = new ListBox.SelectedObjectCollection(listFotos); fotos = listFotos.SelectedItems; if (listFotos.SelectedIndex != -1) { Fotos foto = (Fotos)listFotos.SelectedItem; controladoraFoto.borrarFoto(foto); listFotos.Items.Remove(foto); } else { MessageBox.Show("Debe seleccionar un elemento de la lista"); } }
public List<Usuario> recuperarEtiquetados(ListBox listAmigos) { List<Usuario> miLista = new List<Usuario>(); ListBox.SelectedObjectCollection usuarios = new ListBox.SelectedObjectCollection(listAmigos); usuarios = listAmigos.SelectedItems; if (listAmigos.SelectedIndex != -1) { foreach (Usuario s in usuarios) { miLista.Add(s); } } return miLista; }