using DevExpress.XtraEditors.Repository; using Yw.WinFrmUI.Hydro; namespace Yw.WinFrmUI { public partial class SetHydroMarkCtrl : DevExpress.XtraEditors.XtraUserControl { public SetHydroMarkCtrl() { InitializeComponent(); this.gridView1.SetNormalEditView(); this.colName.OptionsColumn.AllowEdit = false; this.gridView1.CustomRowCellEdit += GridView1_CustomRowCellEdit; } //所有绑定列表 private BindingList _allBindingList = null; /// /// 绑定数据 /// public void SetBindingData(List allSetList) { _allBindingList = new BindingList(); allSetList?.ForEach(x => { _allBindingList.Add(x); }); this.hydroMarkSetViewModelBindingSource.DataSource = _allBindingList; this.hydroMarkSetViewModelBindingSource.ResetBindings(false); } /// /// 获取设置列表 /// public List GetSetList() { return _allBindingList?.ToList(); } //自定义 private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) { var row = this.gridView1.GetRow(e.RowHandle) as HydroMarkSetViewModel; if (row == null) { return; } if (e.Column == this.colMarkType) { var repositoryItem = new RepositoryItemImageComboBox(); switch (row.Code) { case Yw.Hydro.ParterCatalog.Waterbox: { repositoryItem.AddEnum(typeof(eWaterboxMarkType), true); } break; case Yw.Hydro.ParterCatalog.Pump: { repositoryItem.AddEnum(typeof(ePumpMarkType), true); } break; case Yw.Hydro.ParterCatalog.Valve: { repositoryItem.AddEnum(typeof(eValveMarkType), true); } break; case Yw.Hydro.ParterCatalog.Pipe: { repositoryItem.AddEnum(typeof(ePipeMarkType), true); } break; case Yw.Hydro.ParterCatalog.Nozzle: { repositoryItem.AddEnum(typeof(eNozzleMarkType), true); } break; default: break; } e.RepositoryItem = repositoryItem; } } } }