BindingList<VideoInfo> VideoPlayList = null;//定义 VideoPlayList = new BindingList<VideoInfo>(AppManager.CreateInstance().PlayList.VideoList);//List<T>绑定到BindingList; dgvVideo.DataSource = VideoPlayList;//使用BindingList绑定 //增加记录 VideoInfo vInfo = new VideoInfo(); vInfo.VideoName = fileName.Split(new char[] { '.' })[0]; vInfo.VideoAddr = fileDialog.FileName; VideoPlayList.Add(vInfo); dgvVideo.Refresh(); //删除记录 var vInfo = this.dgvVideo.CurrentRow.DataBoundItem as VideoInfo; VideoPlayList.Remove(vInfo); dgvVideo.Refresh();
只需要操作VideoPlayList就可以了。List与BindingList 完全绑定在一起。
标签:vInfo,VideoPlayList,绑定,dgvVideo,DataGridView,BindingList,操作,VideoInfo From: https://www.cnblogs.com/kingkie/p/17203774.html