namespace Yw.WinFrmUI { public partial class HydroNozzleListCtrl : DevExpress.XtraEditors.XtraUserControl { public HydroNozzleListCtrl() { InitializeComponent(); this.gridView1.SetNormalView(30); } /// /// 水力点击事件 /// public event Action HydroClickEvent; private List _allBindingList = null;//所有绑定列表 /// /// 绑定数据 /// /// public void SetBindingData(List allNozzleList) { _allBindingList = new List(); if (allNozzleList != null && allNozzleList.Count > 0) { foreach (var nozzle in allNozzleList) { var vm = new HydroNozzleViewModel(nozzle); _allBindingList.Add(vm); } } this.hydroNozzleViewModelBindingSource.DataSource = _allBindingList; this.hydroNozzleViewModelBindingSource.ResetBindings(false); } //行点击事件 private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { var row = this.gridView1.GetRow(e.RowHandle) as HydroNozzleViewModel; if (row == null) { return; } this.HydroClickEvent?.Invoke(row.Vmo); } } }