using DevExpress.Mvvm.Native; using DevExpress.Xpo.Helpers; using System.Data; namespace Yw.WinFrmUI { public partial class HydroMonitorValueListCtrl : DevExpress.XtraEditors.XtraUserControl { public HydroMonitorValueListCtrl() { InitializeComponent(); this.gridView1.SetNormalEditView(30); this.gridView1.RegistCustomDrawRowIndicator(40); this.colVisualName.OptionsColumn.AllowEdit = false; this.colPropName.OptionsColumn.AllowEdit = false; this.colUnitName.OptionsColumn.AllowEdit = false; this.colDescription.OptionsColumn.AllowEdit = false; } /// /// 查看水力事件 /// public event Action HydroViewEvent; private Yw.Model.HydroVisualInfo _visual = null;//可见构件 private BindingList _allBindingList = null;//所有绑定列表 /// /// 绑定数据 /// public void SetBindingData(List allMonitorValueList, Yw.Model.HydroVisualInfo visual = null) { var allList = allMonitorValueList?.OrderBy(x => x.SortCode).ToList(); if (visual != null) { allList = allList?.Where(x => x.Vmo.Relation == visual.Code).OrderBy(x => x.SortCode).ToList(); } _allBindingList = new BindingList(); allList?.ForEach(x => _allBindingList.Add(x)); this.hydroMonitorValueViewModelBindingSource.DataSource = _allBindingList; this.hydroMonitorValueViewModelBindingSource.ResetBindings(false); } /// /// 设置视图面板 /// public void SetViewBoard() { this.colMonitorValue.OptionsColumn.AllowEdit = false; this.colMonitorValue.ImageOptions.SvgImage = null; } //行点击 private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { var row = this.gridView1.GetRow(e.RowHandle) as HydroMonitorValueViewModel; if (row == null) { return; } this.HydroViewEvent?.Invoke(row.Vmo.Relation); } } }