private void btnRemove_Click(object sender, EventArgs e)
{
// Code to remove the selected value from the list
if (this.listBoxConnName.Items.Count > 0)
{
int IndexToDelete = this.listBoxConnName.SelectedIndex;
this.listBoxConnName.Items.RemoveAt(IndexToDelete);
this.listBoxLocalAddr.Items.RemoveAt(IndexToDelete);
this.listBoxIPAddress.Items.RemoveAt(IndexToDelete);
this.listBoxPort.Items.RemoveAt(IndexToDelete);
if (this.listBoxConnName.Items.Count > 0)
{
this.listBoxConnName.SelectedIndex = this.listBoxConnName.Items.Count - 1;
this.buttonSetAsActive.Enabled = true;
}
}
// The last thing is to check if there is anything in the list, if so then enable the button
// to allow setting an active multicast address
if (this.listBoxConnName.Items.Count == 0)
this.buttonSetAsActive.Enabled = false;
}