-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
34 lines (33 loc) · 1.56 KB
/
Form1.cs
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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace MyComboBoxEdit {
public partial class FormMain : Form {
private ComboBoxHideItemsHelper _comboBoxHideItemsHelper;
public FormMain() {
InitializeComponent();
this.indexesCheckedComboBox.EditValueChanged += indexesCheckedComboBox_EditValueChanged;
this.indexesCheckedComboBox.Properties.EditValueType = DevExpress.XtraEditors.Repository.EditValueTypeCollection.List;
this._comboBoxHideItemsHelper = new ComboBoxHideItemsHelper(comboBoxEdit1);
PopulateIndexes();
}
void PopulateIndexes() {
for (int i = 0; i < comboBoxEdit1.Properties.Items.Count; i++) {
this.indexesCheckedComboBox.Properties.Items.Add(i, comboBoxEdit1.Properties.Items[i].ToString(), i < 2 ? CheckState.Checked : CheckState.Unchecked, true);
}
}
private void indexesCheckedComboBox_EditValueChanged(object sender, EventArgs e) {
_comboBoxHideItemsHelper.Clear();
var checkedItems = indexesCheckedComboBox.Properties.GetCheckedItems() as List<object>;
foreach (var item in checkedItems) {
_comboBoxHideItemsHelper.Add((int)item);
}
return;
}
protected override void OnHandleDestroyed(EventArgs e) {
base.OnHandleDestroyed(e);
_comboBoxHideItemsHelper.Dispose();
this.indexesCheckedComboBox.EditValueChanged -= indexesCheckedComboBox_EditValueChanged;
}
}
}