Exemple #1
0
        private void reverse_btn_Click(object sender, EventArgs e)
        {
            ListBox lb = GetChildeControl <ListBox>(tc_Person.SelectedTab);

            ListBox.ObjectCollection items = lb.Items;

            lb.BeginUpdate();
            for (int i = 0, j = items.Count - 1; i < j; i++, j--)
            {
                object tempI = items[i];
                object tempJ = items[j];

                items.RemoveAt(j);
                items.RemoveAt(i);

                items.Insert(i, tempJ);
                items.Insert(j, tempI);
            }
            lb.EndUpdate();
        }
Exemple #2
0
        AddItem <TItem, TContainedValue>
        (
            TItem item
        )
            where TItem : FormattableValue <TContainedValue>

            where TContainedValue : IEquatable <TContainedValue>,
        IComparable <TContainedValue>, IFormattable
        {
            AssertValid();

            ListBox.ObjectCollection oItems = this.Items;
            Int32 iItems = oItems.Count;
            Int32 iInsertionIndex;

            for (iInsertionIndex = 0; iInsertionIndex < iItems; iInsertionIndex++)
            {
                Debug.Assert(oItems[iInsertionIndex] is TItem);

                TItem oFormattableValue = (TItem)oItems[iInsertionIndex];

                Int32 iCompareTo = item.CompareTo(oFormattableValue);

                if (iCompareTo == 0)
                {
                    // The ListBox contains an item with the same contained value.
                    // Don't add another such item.

                    return;
                }

                if (iCompareTo < 0)
                {
                    break;
                }
            }

            this.ClearSelected();
            oItems.Insert(iInsertionIndex, item);
            this.SelectedIndex = iInsertionIndex;
        }