我在我的WinForms上有一个列表框,用户可以上下移动项目,该列表框与我拥有的列表一样,我想知道什么是保持同步的最有效方式。与列表框同步列表?
例如移动一个项目下来,我有:
int i = this.recoveryList.SelectedIndex;
object o = this.recoveryList.SelectedItem;
if (i < recoveryList.Items.Count - 1)
{
this.recoveryList.Items.RemoveAt(i);
this.recoveryList.Items.Insert(i + 1, o);
this.recoveryList.SelectedIndex = i + 1;
}
而且我有:
public List<RouteList> Recovery = new List<RouteList>();
,我想保持对列表框更新。
我应该简单清楚使用当前列表框数据恢复和更新,还是有更好的方法来更新上下移动?
我主要是问,因为从列表框到列表的类型是不同的。
您使用的是WPF还是WinForms? – 2011-03-21 08:35:35
@Daniel WinForms,thakns询问。 – Prix 2011-03-21 08:36:08