我很难找到一种方法从数据库加载朋友的电子邮件和头像,并将其放入DataGridView或ListView。
当前方法:使用DataGridView:
private void loadData()
{
var query = from o in Globals.DB.Friends
where o.UserEmail == Properties.Settings.Default.Email
select new
{
Avatar = o.Avatar,
FirstName = o.FirstName,
LastName = o.LastName,
Email = o.Email,
Display = o.Avatar + string.Format("{0} {1} - ({2})", o.FirstName, o.LastName, o.Email)
};
FriendsDGV.DataSource = query.ToList();
}
DataGridView不提供值成员或显示成员,但列表框可以:
FriendsLb.DisplayMember = "Display";
FriendsLb.ValueMember = "Avatar";
FriendsLb.ValueMember = "Email";
FriendsLb.ValueMember = "FirstName";
FriendsLb.ValueMember = "LastName";
我需要值和显示成员才能使用它,但DataGridView不能提供它。我没有关于如何将朋友信息和头像加载到数据表单中的想法,例如:列表框,DataGridView或列表视图。列表视图不提供数据源,因此我甚至不知道该怎么做帮助! :(