Select only one item in the middle of two listboxes

0

Oops! Gal, I wanted to select only one item in the middle of two listbox, imagining the listbox to be a radiobutton, if I select an item in one, it is no longer selected in the other. I tried it like this:

private void listBoxQuestoesObjetivas_SelectedIndexChanged(object sender, EventArgs e)
{
    listBoxQuestoesSubjetivas.ClearSelected();
}

private void listBoxQuestoesSubjetivas_SelectedIndexChanged(object sender, EventArgs e)
{
    listBoxQuestoesObjetivas.ClearSelected();
}

The problem is that when I click on one, unselect on both, this is very strange '-' Remembering that I'm using Microsoft.Net Framework 2.0

    
asked by anonymous 20.08.2016 / 16:27

1 answer

0

Try the following, but logically by changing the names of the controls to yours.

    private void listBox1_Click(object sender, EventArgs e)
    {
        listBox2.SelectedIndex = -1;
    }

    private void listBox2_Click(object sender, EventArgs e)
    {
        listBox1.SelectedIndex = -1;
    }

This also works:

    private void listBox1_Click(object sender, EventArgs e)
    {
        listBox2.ClearSelected();
    }

    private void listBox2_Click(object sender, EventArgs e)
    {
        listBox1.ClearSelected();
    }
    
22.08.2016 / 02:24