using System.Data;
|
|
namespace Yw.WinFrmUI
|
{
|
public partial class HydroPumpListExtendGridCtrl : DevExpress.XtraEditors.XtraUserControl
|
{
|
public HydroPumpListExtendGridCtrl()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalEditView();
|
}
|
|
/// <summary>
|
/// 状态改变事件
|
/// </summary>
|
public event Action<List<HydroPumpListItemExtendViewModel>> StateChangedEvent;
|
|
private BindingList<HydroPumpListItemExtendViewModel> _allBindingList = null;//绑定列表
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
|
{
|
SetBindingData(hydroInfo?.Pumps, hydroInfo);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(List<Yw.Model.HydroPumpInfo> allPumpList, Yw.Model.HydroModelInfo hydroInfo)
|
{
|
var list = allPumpList?.Select(x => new HydroPumpListItemExtendViewModel(x, allPumpList, hydroInfo)).ToList();
|
SetBindingData(list);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
public void SetBindingData(List<HydroPumpListItemExtendViewModel> allList)
|
{
|
_allBindingList = new BindingList<HydroPumpListItemExtendViewModel>();
|
allList?.ForEach(x => _allBindingList.Add(x));
|
this.hydroPumpListItemExtendViewModelBindingSource.DataSource = _allBindingList;
|
this.hydroPumpListItemExtendViewModelBindingSource.ResetBindings(false);
|
}
|
|
/// <summary>
|
/// 获取状态列表
|
/// </summary>
|
public List<HydroPumpListItemExtendViewModel> GetStateList()
|
{
|
return _allBindingList?.ToList();
|
}
|
|
//值改变事件
|
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
{
|
this.StateChangedEvent?.Invoke(_allBindingList?.ToList());
|
}
|
|
|
}
|
}
|