Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12439770
  • 博文数量: 1293
  • 博客积分: 13501
  • 博客等级: 上将
  • 技术积分: 17974
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-08 18:11
文章分类

全部博文(1293)

文章存档

2019年(1)

2018年(1)

2016年(118)

2015年(257)

2014年(128)

2013年(222)

2012年(229)

2011年(337)

分类: C#/.net

2016-01-15 18:40:27

1、New和Update时使用

this.dataGrid1.Items.Refresh();

2、数据绑定

public class DgStaffInfo : INotifyPropertyChanged
{
    private int mId;
    private string mName;

    public string Name
    {
        get { return mName; }
        set { mName = value; }
    }
    public int ID
    {
        get { return mId; }
        set { mId = value; }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(string info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
        }
    }
}
image

数据源的创建、填充、和绑定

this.mStaffInfoList = new ObservableCollection();

mStaffInfoList.Add(new DgStaffInfo { ID = records[i].ID, Name = records[i].Name });

this.dataGrid1.ItemsSource = mStaffInfoList;

阅读(2467) | 评论(0) | 转发(0) |
0

上一篇:List Find & Findindex

下一篇:WPF的DoEvents

给主人留下些什么吧!~~