namespace Yw.WinFrmUI { public partial class HydroSinglePumpListExtendGridCtrl : DevExpress.XtraEditors.XtraUserControl { public HydroSinglePumpListExtendGridCtrl() { InitializeComponent(); this.gridView1.SetNormalEditView(); this.colName.OptionsColumn.AllowEdit = false; this.colN.OptionsColumn.AllowEdit = false; } /// /// 状态改变事件 /// public event Action> StateChangedEvent; private BindingList _allBindingList = null;//绑定列表 /// /// 是否改变 /// public bool HasChanged { get; set; } /// /// /// public void SetBindingData(Yw.Model.HydroPumpInfo pump) { if (pump == null) { return; } var list = new List() { new HydroSinglePumpListItemExtendViewModel(pump,true), new HydroSinglePumpListItemExtendViewModel(pump,false) }; SetBindingData(list); } /// /// /// public void SetBindingData(List allList) { _allBindingList = new BindingList(); allList?.ForEach(x => _allBindingList.Add(x)); this.hydroSinglePumpListItemExtendViewModelBindingSource.DataSource = _allBindingList; this.hydroSinglePumpListItemExtendViewModelBindingSource.ResetBindings(false); } /// /// 获取状态列表 /// public List GetStateList() { return _allBindingList?.ToList(); } //值改变事件 private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { this.HasChanged = true; this.StateChangedEvent?.Invoke(_allBindingList?.ToList()); } private void gridView1_ShowingEditor(object sender, CancelEventArgs e) { var vm = this.gridView1.GetFocusedRow() as HydroSinglePumpListItemExtendViewModel; if (vm == null) { return; } if (vm.IsRated) { e.Cancel = true; } } } }