Ejemplo n.º 1
0
        private void AutoCompleteFinished()
        {
            //Console.WriteLine("{0} Show results {1}", Environment.TickCount % 10000, autocompletestrings.Count);
            inautocomplete = false;

            if (autocompletestrings.Count > 0)
            {
                if (_cbdropdown != null)
                {
                    _cbdropdown.Close();
                }

                _cbdropdown = new ComboBoxCustomDropdown();

                int fittableitems = this.DropDownHeight / this.DropDownItemHeight;

                if (fittableitems == 0)
                {
                    fittableitems = 5;
                }

                if (fittableitems > autocompletestrings.Count())                             // no point doing more than we have..
                {
                    fittableitems = autocompletestrings.Count();
                }

                _cbdropdown.Size = new Size(this.DropDownWidth > 0 ? this.DropDownWidth : this.Width, fittableitems * this.DropDownItemHeight + 4);

                _cbdropdown.SelectionBackColor = this.DropDownBackgroundColor;
                _cbdropdown.ForeColor          = this.ForeColor;
                _cbdropdown.BackColor          = this.DropDownBorderColor;
                _cbdropdown.BorderColor        = this.DropDownBorderColor;
                _cbdropdown.Items                    = autocompletestrings;
                _cbdropdown.ItemHeight               = this.DropDownItemHeight;
                _cbdropdown.SelectedIndex            = 0;
                _cbdropdown.FlatStyle                = this.FlatStyle;
                _cbdropdown.Font                     = this.Font;
                _cbdropdown.ScrollBarColor           = this.DropDownScrollBarColor;
                _cbdropdown.ScrollBarButtonColor     = this.DropDownScrollBarButtonColor;
                _cbdropdown.MouseOverBackgroundColor = this.DropDownMouseOverBackgroundColor;

                _cbdropdown.DropDown             += _cbdropdown_DropDown;
                _cbdropdown.SelectedIndexChanged += _cbdropdown_SelectedIndexChanged;
                _cbdropdown.KeyPressed           += _cbdropdown_KeyPressed;
                _cbdropdown.OtherKeyPressed      += _cbdropdown_OtherKeyPressed;
                _cbdropdown.Deactivate           += _cbdropdown_Deactivate;

                Control parent = this.Parent;
                while (parent != null && !(parent is Form))
                {
                    parent = parent.Parent;
                }

                _cbdropdown.Show(parent);
            }
        }
Ejemplo n.º 2
0
        private void _cbdropdown_DropDownClosed(object sender, EventArgs e)
        {
            if (_cbdropdown != null)
            {
                _cbdropdown.Dispose();
                _cbdropdown = null;
            }

            isActivated = false;
        }
Ejemplo n.º 3
0
        private void Activate()
        {
            if (Items.Count == 0 || !Enabled)
            {
                return;
            }

            _cbdropdown = new ComboBoxCustomDropdown(this.Name);

            int fittableitems = this.DropDownHeight / this.ItemHeight;

            if (fittableitems == 0)
            {
                fittableitems = 5;
            }

            if (fittableitems > this.Items.Count())                             // no point doing more than we have..
            {
                fittableitems = this.Items.Count();
            }

            _cbdropdown.Size = new Size(this.DropDownWidth > 9 ? this.DropDownWidth : this.Width, fittableitems * this.ItemHeight + 4);

            _cbdropdown.SelectionBackColor       = this.DropDownBackgroundColor;
            _cbdropdown.MouseOverBackgroundColor = this.MouseOverBackgroundColor;
            _cbdropdown.ForeColor            = this.ForeColor;
            _cbdropdown.BackColor            = this.BorderColor;
            _cbdropdown.BorderColor          = this.BorderColor;
            _cbdropdown.Items                = this.Items.ToList();
            _cbdropdown.ItemHeight           = this.ItemHeight;
            _cbdropdown.SelectedIndex        = this.SelectedIndex;
            _cbdropdown.FlatStyle            = this.FlatStyle;
            _cbdropdown.Font                 = this.Font;
            _cbdropdown.ScrollBarColor       = this.ScrollBarColor;
            _cbdropdown.ScrollBarButtonColor = this.ScrollBarButtonColor;

            _cbdropdown.DropDown             += _cbdropdown_DropDown;
            _cbdropdown.SelectedIndexChanged += _cbdropdown_SelectedIndexChanged;
            _cbdropdown.OtherKeyPressed      += _cbdropdown_OtherKeyPressed;
            _cbdropdown.Deactivate           += _cbdropdown_Deactivate;

            Control parent = this.Parent;

            while (parent != null && !(parent is Form))
            {
                parent = parent.Parent;
            }

            _cbdropdown.Show(parent);

            // enforce size.. some reason SHow is scaling it probably due to autosizing.. can't turn off. force back
            _cbdropdown.Size = new Size(this.DropDownWidth > 9 ? this.DropDownWidth : this.Width, fittableitems * this.ItemHeight + 4);
        }
Ejemplo n.º 4
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            _cbdropdown = new ComboBoxCustomDropdown();

            int fittableitems = this.DropDownHeight / this.ItemHeight;

            if (fittableitems == 0)
            {
                fittableitems = 5;
            }

            if (fittableitems > this.Items.Count())                             // no point doing more than we have..
            {
                fittableitems = this.Items.Count();
            }

            _cbdropdown.Size = new Size(this.DropDownWidth, fittableitems * this.ItemHeight + 4);

            _cbdropdown.SelectionBackColor = this.DropDownBackgroundColor;
            _cbdropdown.ForeColor          = this.ForeColor;
            _cbdropdown.BackColor          = this.BorderColor;
            _cbdropdown.BorderColor        = this.BorderColor;
            _cbdropdown.Items                = this.Items.ToList();
            _cbdropdown.ItemHeight           = this.ItemHeight;
            _cbdropdown.SelectedIndex        = this.SelectedIndex;
            _cbdropdown.FlatStyle            = this.FlatStyle;
            _cbdropdown.Font                 = this.Font;
            _cbdropdown.ScrollBarColor       = this.ScrollBarColor;
            _cbdropdown.ScrollBarButtonColor = this.ScrollBarButtonColor;

            _cbdropdown.DropDown             += _cbdropdown_DropDown;
            _cbdropdown.DropDownClosed       += _cbdropdown_DropDownClosed;
            _cbdropdown.SelectedIndexChanged += _cbdropdown_SelectedIndexChanged;

            Control parent = this.Parent;

            while (parent != null && !(parent is Form))
            {
                parent = parent.Parent;
            }

            _cbdropdown.Show(parent);
        }