【发布时间】:2013-03-11 21:36:03
【问题描述】:
我将 listbox1 设置为使用名为“serverList”的列表的数据源。当我跑步时
public void button2_Click(object sender, EventArgs e)
{
if (folderPath != "\\realmlist.wtf" && folderPath != "none")
{
serverList.Add(newServer);
listBox1.DataSource = serverList;
File.WriteAllText(folderPath, "Set realmlist " + newServer);
}
}
第一个字符串进入并显示在列表框中就好了,但是当我尝试将另一个字符串添加到列表中时,它不会显示在列表框中,但实际上在列表中。我该怎么做才能做到这一点?
【问题讨论】:
-
您是否尝试在将字符串添加到列表后重新绑定数据?即,
listBox1.DataBind();分配 DataSource 之后?
标签: c# list listbox refresh datasource