月夜钓钱江鱼

醉后不知天在水,满船清梦压星河。

 

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 完全绑定在一起。

posted on 2023-03-10 16:15  湘灵  阅读(73)  评论(0编辑  收藏  举报