Ive gotten error messsages that the selceted index is out of range, i have checked several times and it should not be. I want ot remove the selected index from both the listbox and the list. Can anyone help me?
Remove selected index:
private void RemoveButton_Click(object sender, EventArgs e)
{
if (CartListBox.SelectedIndex != -1)
{
var price = CartProduct[CartListBox.SelectedIndex].GetSetProPrice;
CartListBox.Items.RemoveAt(CartListBox.SelectedIndex);
CartProduct.RemoveAt(CartListBox.SelectedIndex); //outside index??
}
}