using System; using System.ComponentModel; using System.Windows.Forms; namespace Oli.Controls.Tests { public partial class TestDragDropListBox : UserControl { public TestDragDropListBox() { InitializeComponent(); dragDropListBoxBindingSource.DataSource = dragDropListBox; cboSelectionMode.DataSource = Enum.GetNames(typeof(SelectionMode)); cboSelectionMode.Text = "MultiExtended"; } public void AddItemsRange(object[] items) { dragDropListBox.Items.AddRange(items); } [Category("Behavior (drag-and-drop)"), DefaultValue(""), Description("Drag-and-drop group to which the DragDropListBox belongs. Drag-and-drop is restricted to happen between DragDropListBoxes having the same DragDropGroup.")] public string DragDropGroup { get { return dragDropListBox.DragDropGroup; } set { txtGroup.Text = value; dragDropListBox.DragDropGroup = value; } } private void cboSelectionMode_SelectedIndexChanged(object sender, EventArgs e) { dragDropListBox.SelectionMode = (SelectionMode)Enum.Parse(typeof(SelectionMode), cboSelectionMode.Text); } private void btnSelectEven_Click(object sender, EventArgs e) { for (int i = 0; i < dragDropListBox.Items.Count; i++) { dragDropListBox.SetSelected(i, i % 2 == 0); } } private void chkSorted_CheckedChanged(object sender, EventArgs e) { dragDropListBox.Sorted = chkSorted.Checked; // DataBinding doesn't work well (list isn't sorted immediately). } } }