listbox Refresh() in c#

前端 未结 10 2392
梦毁少年i
梦毁少年i 2020-12-30 10:54
int[] arr = int[100];
listBox1.DataSource = arr;
void ComboBox1SelectedIndexChanged(object sender, EventArgs e)
{
    .....//some processes
    listBox1.DataSource =         


        
10条回答
  •  攒了一身酷
    2020-12-30 11:35

    The problem might come from the ListBox SelectionMode.

    For a reason that I don't know, the databinding does not work when SelectionMode is SelectionMode.None.

    A workaround could be:

    listBox.SelectionMode = SelectionMode.MultiExtended;
    listBox.DataSource = myDatasource;
    listBox.SelectionMode = SelectionMode.None;
    

    Hope it helps.

提交回复
热议问题