tangxu
2025-01-13 4f7cb65b079d88d5a829688b24d26d5145c5df47
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DPumpHydr.WinFrmUI.WenSkin.Controls;
 
namespace DPumpHydr.WinFrmUI.WenSkin.Design.Editor
{
    public class WenDataGridViewComboBoxCollectionEditor : WenCollectionEditor
    {
        public WenDataGridViewComboBoxCollectionEditor(Type type) : base(type)
        {
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (value is WenDataGridViewComboBoxColumn.ObjectCollection items)
            {
                string str = "";
                foreach (var item in items)
                {
                    str += item?.ToString() + "\r\n";
                }
                if (str.Length > 2)
                    str.Remove(str.Length - 2, 2);
 
                var picker = new EditForm.MultilineTextEditForm(str);
                if (picker.ShowDialog() == DialogResult.OK)
                {
                    items.Clear();
                    items.AddRange(picker.Message.Replace("\r", "").Split('\n'));
                    MessageBox.Show(items.Count.ToString());
                    return items;
                }
            }
            return value;
        }
 
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }
    }
}