private void mnuDeleteItem_Click(object sender, EventArgs e) { // get the line from the window if (lstItems.Items.Count == 0) { return; // no items. } if (lstItems.SelectedIndex == -1) { return; // nada selected. } string line = lstItems.GetItemText(lstItems.Items[lstItems.SelectedIndex]); // parse out the id if (line.IndexOf("(") >= 0) { if (line.IndexOf(")") >= 0) // this check is probably unnecessary. { int beginning = line.LastIndexOf("(") + 1; int end = line.LastIndexOf(")"); line = line.Substring(beginning, end - beginning); // send the objvars command. CsToolClass.getInstance().sendMessage("delete_object " + line); // and update. CsToolClass.getInstance().sendMessage("get_pc_info " + txtPlayerName.Text); } } getCharacterData(); }
private void btnEditar_Click(object sender, System.EventArgs e) { txtDesignacao.Tag = lstValores.SelectedItem; txtDesignacao.Text = lstValores.GetItemText(lstValores.SelectedItem); EnterEditMode(); UpdateButtonStateDesignacao(); }
internal void SetItemInternal(int index, object value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (index < 0 || index >= InnerArray.GetCount(0)) { throw new ArgumentOutOfRangeException(nameof(index), index, string.Format(SR.InvalidArgument, nameof(index), index)); } owner.UpdateMaxItemWidth(InnerArray.GetItem(index, 0), true); InnerArray.SetItem(index, value); // If the native control has been created, and the display text of the new list item object // is different to the current text in the native list item, recreate the native list item... if (owner.IsHandleCreated) { bool selected = (owner.SelectedIndex == index); if (string.Compare(owner.GetItemText(value), owner.NativeGetItemText(index), true, CultureInfo.CurrentCulture) != 0) { owner.NativeRemoveAt(index); owner.SelectedItems.SetSelected(index, false); owner.NativeInsert(index, value); owner.UpdateMaxItemWidth(value, false); if (selected) { owner.SelectedIndex = index; } } else { // FOR COMPATIBILITY REASONS if (selected) { owner.OnSelectedIndexChanged(EventArgs.Empty); //will fire selectedvaluechanged } } } owner.UpdateHorizontalExtent(); }
public override void DrawListBoxItem (ListBox ctrl, DrawItemEventArgs e) { Color back_color, fore_color; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { back_color = ColorHighlight; fore_color = ColorHighlightText; } else { back_color = e.BackColor; fore_color = e.ForeColor; } e.Graphics.FillRectangle (ResPool.GetSolidBrush (back_color), e.Bounds); e.Graphics.DrawString (ctrl.GetItemText (ctrl.Items[e.Index]), e.Font, ResPool.GetSolidBrush (fore_color), e.Bounds, ctrl.StringFormat); if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) CPDrawFocusRectangle (e.Graphics, e.Bounds, fore_color, back_color); }
private void button2_Click(object sender, System.EventArgs e) { Geral.ECF.Deletar_Registro(ListCodigo.GetItemText(ListCodigo.SelectedItem)); }
//Delete button function private void btnDeleteFlag_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex == -1) { MessageBox.Show("Please select item to delete.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int index = 0; string value = listBox1.GetItemText(listBox1.SelectedItem); char[] charArray = value.ToCharArray(); //Convert the list item into char array for (int i = 0; i < charArray.Length; i++) { //Find the x and y starting position if (charArray[i] == '(') { index = i; } } string x = value.Substring(index + 1, 3).ToString(); string y = value.Substring(index + 5, 3).ToString(); int X_Point = Convert.ToInt32(x); int Y_Point = Convert.ToInt32(y); if ((value.Contains("Sri Lanka")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("India")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("USA")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("Canada")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("Mexico")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("Argentina")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("Brazil")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("UK")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("France")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("Australia")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("New Zealand")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("South Africa")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } else if ((value.Contains("Zimbabwe")) == true) { listBox1.Items.Remove(listBox1.SelectedItem); deleteSelectedFlag(X_Point, Y_Point);//Delete selected flag } } }