using System; using System.Collections.Generic; using System.Windows.Forms; namespace Uninpho.Tools.components.DataManager { public partial class FrmSetting : DevExpress.XtraEditors.XtraForm { public Dictionary Condition = new Dictionary(); public FrmSetting(Dictionary filterCondition) { InitializeComponent(); setUI(filterCondition); } private void setUI(Dictionary filterCondition) { foreach (var item in this.Controls) { if (item is GroupBox) { foreach (var ctl in (item as GroupBox).Controls) { if (ctl is CheckBoxInput) { foreach (KeyValuePair kvp in filterCondition) { bool isChecked = kvp.Key == (ctl as CheckBoxInput).ColumnName; if (isChecked) { (ctl as CheckBoxInput).Checked = isChecked; (ctl as CheckBoxInput).Value = kvp.Value; break; } } } } } } } private void btnOK_Click(object sender, EventArgs e) { foreach (var item in this.Controls) { if (item is GroupBox) { foreach (var ctl in (item as GroupBox).Controls) { if (ctl is CheckBoxInput&& (ctl as CheckBoxInput).Checked&& (ctl as CheckBoxInput).Value!=0) { this.Condition.Add((ctl as CheckBoxInput).ColumnName, (ctl as CheckBoxInput).Value); } } } } this.DialogResult = DialogResult.OK; } private void btnCancle_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } private void checkBoxInput9_Load(object sender, EventArgs e) { } } }