将对象数据绑定列表添加到数据网格视图

时间:2016-06-27 04:47:53

标签: vb.net winforms data-binding

我有这个手册在网格中添加数据或行,我想问一下如何在vb.net中实现数据绑定。

memberGrid.Rows.Clear()

For Each m As Member In members
    Dim row As Object() = {m.MemberId, EntityHelper.FullName(m.Person.FirstName, m.Person.SurName),
                                   WorkoutLogic.GetLastWorkoutDateDisplay(m.MemberId, AppRuntime.Workouts),
                                   LogicService.GetMembershipStatus(m.MembershipHistories),
                                    m.Person.Mobile}
    memberGrid.Rows.Add(row)
Next

1 个答案:

答案 0 :(得分:0)

尝试类似

的内容
memberGrid.DataSource = (From m In members
                         Select New With { Id = m.MemberId,
                                           FullName = EntityHelper.FullName(m.Person.FirstName, m.Person.SurName),
                                           LastWorkout = WorkoutLogic.GetLastWorkoutDateDisplay(m.MemberId, AppRuntime.Workouts), 
                                           Status = LogicService.GetMembershipStatus(m.MembershipHistories), 
                                           Mobile = m.Person.Mobile }).ToList()

更改=之前的名称以匹配列的名称。