// // Copyright (c) jindongfang. All rights reserved. // using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace WellWorkDataUI { /// /// FrmSelectColumn /// public partial class FrmSelectColumn : DevExpress.XtraEditors.XtraForm { private readonly List columns; /// /// SelectedColumns /// public List SelectedColumns { get; } = new List(); /// /// Initializes a new instance of the class. /// /// columns public FrmSelectColumn(List columns) { this.InitializeComponent(); this.columns = columns; this.checkedListBoxControl.DataSource = columns; } private void btnOK_Click(object sender, EventArgs e) { var list = this.checkedListBoxControl.CheckedItems.OfType().ToList(); this.SelectedColumns.AddRange(list); this.DialogResult = DialogResult.OK; } private void btnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } private void btnReverseCheck_Click(object sender, EventArgs e) { for (int i = 0; i < this.checkedListBoxControl.ItemCount; i++) { bool bCheck = this.checkedListBoxControl.GetItemChecked(i); this.checkedListBoxControl.SetItemChecked(i, !bCheck); } } private void btnUncheckAll_Click(object sender, EventArgs e) { this.checkedListBoxControl.UnCheckAll(); } private void btnCheckAll_Click(object sender, EventArgs e) { this.checkedListBoxControl.CheckAll(); } } }