using Models; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace LeatherApp.UIExtend { public partial class UIDefectEdit : UserControl { /// /// code,name /// public Action CodeChangeEvent; public UIDefectEdit() { InitializeComponent(); init(); } private void init() { var list = Config.defectItemList.Select(x => new { code = x.Value("code"), name = x.Value("name") }).ToList(); uiComboBox1.ValueMember = "code"; uiComboBox1.DisplayMember = "name"; uiComboBox1.DataSource = list; } [Description("忽略"), Category("自定义")] public bool Checked { get { return this.uiCheckBox1.Checked; } set { this.uiCheckBox1.Checked = value; } } [Description("瑕疵"), Category("自定义")] public string Code { get { return this.uiComboBox1.SelectedValue.ToString(); } set { this.uiComboBox1.SelectedValue = value; } } private void uiComboBox1_SelectedIndexChanged(object sender, EventArgs e) { string code = uiComboBox1.SelectedValue.ToString(); string name = uiComboBox1.SelectedText.ToString(); if (this.Tag != null) { var item = (DefectInfo)this.Tag; item.Code = code; item.Name = name; } CodeChangeEvent?.Invoke(code,name); } } }