コード例 #1
0
        private void CloseListBox()
        {
            listBoxOpened = false;

            if (listBoxPanel == null)
            {
                return;
            }

            listBoxPanel.listBox.SelectedIndexChanged -= ListBoxOnSelectedIndexChanged;
            listBoxPanel.listBox.MouseUp  -= ListBoxOnMouseUp;
            listBoxPanel.listBox.KeyDown  -= ListBoxOnKeyDown;
            listBoxPanel.listBox.Disposed -= ListBoxOnDisposed;
            listBoxPanel.Dispose();
            listBoxPanel = null;

            OnDropDownClosed(EventArgs.Empty);

            listBoxRecentlyClosed = true;
        }
コード例 #2
0
        private void CreateListBox()
        {
            if (listBoxPanel != null)
            {
                listBoxPanel = null;
                return;
            }

            if (listBoxRecentlyClosed)
            {
                return;
            }

            var screenLocation = PointToScreen(Point.Empty);
            var height         = ItemHeight * (Items.Count > MaxDropDownItems ? MaxDropDownItems : Items.Count);

            if (height < ItemHeight)
            {
                height = ItemHeight;
            }

            listBoxPanel          = new ComboListBoxPanel(this);
            listBoxPanel.Location = new Point(screenLocation.X, screenLocation.Y + Height);
            listBoxPanel.Size     = new Size(Width, height + 4); // + Vertical padding for borders.
            listBoxPanel.InitializeComponent();

            listBoxPanel.listBox.SelectedIndexChanged += ListBoxOnSelectedIndexChanged;
            listBoxPanel.listBox.MouseUp  += ListBoxOnMouseUp;
            listBoxPanel.listBox.KeyDown  += ListBoxOnKeyDown;
            listBoxPanel.listBox.Disposed += ListBoxOnDisposed;

            listBoxPanel.uwfContext = true;

            listBoxPanel.UpdateListBoxItems(string.Empty);

            OnDropDown(EventArgs.Empty);

            listBoxOpened = true;
        }
コード例 #3
0
        private void ApplySelectedItem()
        {
            if (listBoxPanel == null)
            {
                return;
            }
            var listSelectedItem = listBoxPanel.listBox.SelectedItem;

            for (int i = 0; i < Items.Count; i++)
            {
                if (Items[i] != listSelectedItem)
                {
                    continue;
                }

                Text = listSelectedItem != null?listSelectedItem.ToString() : "";

                SelectedItem = listSelectedItem;
                break;
            }

            listBoxPanel.Dispose();
            listBoxPanel = null;
        }