How to clean ListBox

2

How to clean a ListBox ?

I made these forms but they did not work:

private void LimparListBox()
{
    //lbxResumo.Text = "";
    lbxResumo.ClearSelected();
}

private void btnLimparList_Click(object sender, EventArgs e)
{
    LimparListBox();
}
    
asked by anonymous 08.11.2017 / 16:51

2 answers

1

You need Items.Clear() to clear the textbox.

Example:

private void LimparListBox()
{
    //lbxResumo.Text = "";
    lbxResumo.Items.Clear();
}

private void btnLimparList_Click(object sender, EventArgs e)
{
    LimparListBox();
}

Source: link

    
08.11.2017 / 17:01
0

The correct command would be:

List.Items.Clear

Put the name of your ListBox in place of List

The example you used:

lbxResumo.ClearSelected();

clean only the selected item.

    
08.11.2017 / 17:00