您可以处理绑定列表的ListChanged事件,并保留已添加项目的引用。
例子:
class Program
{
static object last_item;
static void Main(string[] args)
{
BindingList<object> WorkoutScheduleList = new BindingList<object>();
WorkoutScheduleList.ListChanged += (s, e) => {
if (e.ListChangedType == ListChangedType.ItemAdded)
last_item = WorkoutScheduleList[e.NewIndex];
};
WorkoutScheduleList.Add("Foo");
WorkoutScheduleList.Add("Bar");
WorkoutScheduleList.Insert(1, "FooBar");
//prints FooBar
Console.WriteLine(String.Format("last item added: {0}", last_item));
}
}