R
Ron
I've got a listbox that holds a list of groups. Users can
select a group, hit the remove button and the group
should be removed from the listbox. The only problem is
that no matter which group you select, the first one in
the listbox is always removed.(The listitem with an index
of 0. Box is set to single selection mode) I've looked at
multiple examples and they all do it this way. What's
wrong? (variables are also being set to the values of the
first item)
private void RemoveGroupButton_Click(object sender,
System.EventArgs e)
{
string groupName;
string toolID;
groupName = GroupsListBox.SelectedItem.ToString();
toolID = GroupsListBox.SelectedValue;
//Remove from the listbox
//************************************************
**********************
GroupsListBox.Items.Remove
(GroupsListBox.SelectedItem);
//************************************************
**********************
}//End Button
select a group, hit the remove button and the group
should be removed from the listbox. The only problem is
that no matter which group you select, the first one in
the listbox is always removed.(The listitem with an index
of 0. Box is set to single selection mode) I've looked at
multiple examples and they all do it this way. What's
wrong? (variables are also being set to the values of the
first item)
private void RemoveGroupButton_Click(object sender,
System.EventArgs e)
{
string groupName;
string toolID;
groupName = GroupsListBox.SelectedItem.ToString();
toolID = GroupsListBox.SelectedValue;
//Remove from the listbox
//************************************************
**********************
GroupsListBox.Items.Remove
(GroupsListBox.SelectedItem);
//************************************************
**********************
}//End Button