(自学日记)DevExpress GridView 解决绑定List,不能自动更新的问题。

初学小白什么都不懂,在网上查了很久的结果是绑定List是不会自动更新的,要用BindingList来实现,直接用也只能更新List增减行,修改某个数值Gridview是不会自动更新的,需要用接口INotifyPropertyChanged来实现。

public class ClassBox: INotifyPropertyChanged
{
    private int _boxID;
    private float _width;
    private string _comment;
    private string _updateTime;
    private string _addTime;
    private List<ClassProduct> _product = new List<ClassProduct>();
    /// <summary>
    /// 箱码
    /// </summary>
    public int BoxID
    {
        get { return _boxID; }
        set
        {
            if (value != _boxID)
            {
                _boxID = value;
                NotifyPropertyChanged();
            }
        }
    }
    /// <summary>
    /// 箱子重量
    /// </summary>
    public float Weight
    {
        get { return _width; }
        set
        {
            if (value != _width)
            {
                _width = value;
                NotifyPropertyChanged();
            }
        }
    }
    /// <summary>
    /// 备注
    /// </summary>
    public string Comment
    {
        get { return _comment; }
        set
        {
            if (value != _comment)
            {
                _comment = value;
                NotifyPropertyChanged();
            }
        }
    }
    /// <summary>
    /// 最近更新时间
    /// </summary>
    public string UpdateTime
    {
        get { return _updateTime; }
        set
        {
            if (value != _updateTime)
            {
                _updateTime = value;
                NotifyPropertyChanged();
            }
        }
    }
    /// <summary>
    /// 添加时间
    /// </summary>
    public string AddTime
    {
        get { return _addTime; }
        set
        {
            if (value != _addTime)
            {
                _addTime = value;
                NotifyPropertyChanged();
            }
        }
    }
    /// <summary>
    /// 箱内物品
    /// </summary>
    public List<ClassProduct> Product
    {
        get { return _product; }
        set
        {
            if (value != _product)
            {
                _product = value;
                NotifyPropertyChanged();
            }
        }
    }
    public ClassBox()
    {
       // Product = new List<ClassProduct>();
    }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值