我在我的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