listbox Refresh() in c#

前端 未结 10 2409
梦毁少年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:46

    my first answer on stack exchange here.

    C# .Net 4.0:

    listBox1.DataSource = null;
    listBox1.DataSource = names;
    

    I noticed that setting the datasource for the first time, it refreshes. When it's set, and you try set it to the same one again, it doesn't update.

    So I made it null, set it to the same one, and it displayed correctly for me with this issue.

提交回复
热议问题