lixiaojun
2024-11-03 7507591ef45cfa8f1080f6dbf68b411edcc7f086
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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<HydroMarkSetViewModel> _allBindingList = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<HydroMarkSetViewModel> allSetList)
        {
            _allBindingList = new BindingList<HydroMarkSetViewModel>();
            allSetList?.ForEach(x =>
            {
                _allBindingList.Add(x);
            });
            this.hydroMarkSetViewModelBindingSource.DataSource = _allBindingList;
            this.hydroMarkSetViewModelBindingSource.ResetBindings(false);
        }
 
        /// <summary>
        /// 获取设置列表
        /// </summary>
        public List<HydroMarkSetViewModel> 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;
            }
        }
 
 
    }
}