Shuxia Ning
2024-11-25 d4898c5d7e1bbbbba384a0e29f29c066d6f502a7
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
using DevExpress.Mvvm.Native;
using DevExpress.XtraEditors.Repository;
 
namespace Yw.WinFrmUI
{
    public partial class ApplyHydroGradingCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public ApplyHydroGradingCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalEditView();
            this.colCatalogName.OptionsColumn.AllowEdit = false;
            this.gridView1.CustomRowCellEdit += GridView1_CustomRowCellEdit;
        }
 
        private BindingList<HydroGradingApplyViewModel> _allBindingList = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<HydroGradingApplyViewModel> allApplyList)
        {
            _allBindingList = new BindingList<HydroGradingApplyViewModel>();
            allApplyList?.ForEach(x =>
            {
                _allBindingList.Add(x);
            });
            this.hydroGradingApplyViewModelBindingSource.DataSource = _allBindingList;
            this.hydroGradingApplyViewModelBindingSource.ResetBindings(false);
        }
 
        /// <summary>
        /// 获取应用列表
        /// </summary>
        public List<HydroGradingApplyViewModel> GetApplyList()
        {
            return _allBindingList?.ToList();
        }
 
        //自定义
        private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
        {
            var row = this.gridView1.GetRow(e.RowHandle) as HydroGradingApplyViewModel;
            if (row == null)
            {
                return;
            }
            if (e.Column == this.colPropName)
            {
                var repositoryItem = new RepositoryItemImageComboBox();
                var dict = HydroGradingPropHelper.GetDict(row.Catalog);
                dict?.ForEach(x => repositoryItem.Items.Add(x.Value, x.Key, -1));
                e.RepositoryItem = repositoryItem;
            }
        }
 
 
    }
}