private void config_Remove() { int index = list_TextFirst.SelectedIndex == -1 ? list_TextLast.SelectedIndex : list_TextFirst.SelectedIndex; if (index == -1) { MessageBox.Show("Please choose on list box text to remove it"); return; } if (MessageBox.Show("You will remove config choose ?", "Are you sure ?", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { long id = ((long)(list_TextFirst.Items[index] as ComboboxItem).Value); bool val = db.RemoveItemByKeyFieldSyncEdit(typeof(CNSPLIT).Name, id); if (val) { list_TextFirst.Items.RemoveAt(index); list_TextLast.Items.RemoveAt(index); //txt_TextFirst.Reset(); //txt_TextLast.Reset(); } else { MessageBox.Show("Remove object fail"); } } }