Hi,
I want to find an Index of a combobox using numbers in the text of a textbox, and then remove them. The items that populate the combobox belong to a data base so I use the Delete method to remove the rows.
EDITED:
I've been reading and the findstring finds text within the item list, not the index. Is there anyway to look for the text in the textbox in the index of the combobox?
Can anyone find the problem with this code?
private void button4_Click(object sender, EventArgs e)
{
int buscar;
buscar = comboBox1.FindStringExact(tNumEditBox3.Text, 0);
comboBox1.SelectedIndex = buscar;
if (comboBox1.SelectedIndex >= 0 && radioButton1.Checked == true)
{
CambiosEnviosDataSet.CambioGRow borrarCambioGFila;
borrarCambioGFila = cambiosEnviosDataSet.CambioG.FindByCambioGID(Convert.ToInt16(tNumEditBox3.Text));
borrarCambioGFila.Delete();
this.cambioGTableAdapter.Update(this.cambiosEnviosDataSet.CambioG);
CambiosEnviosDataSet.CambioERow borrarCambioEFila;
borrarCambioEFila = cambiosEnviosDataSet.CambioE.FindByCambioEID(Convert.ToInt16(tNumEditBox3.Text));
borrarCambioEFila.Delete();
this.cambioETableAdapter.Update(this.cambiosEnviosDataSet.CambioE);
}
else if (comboBox2.SelectedIndex <= 0 && radioButton2.Checked == true)
{
CambiosEnviosDataSet.EnviosRow borrarEnvioFila;
borrarEnvioFila = cambiosEnviosDataSet.Envios.FindByEnvioID(Convert.ToInt16(tNumEditBox3.Text));
borrarEnvioFila.Delete();
this.enviosTableAdapter.Update(this.cambiosEnviosDataSet.Envios);
}
else
{
MessageBox.Show("The key you are using is not in the index");
}
}