Exemple #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);
            }
        }
Exemple #2
0
        private void _cbdropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedindex = _cbdropdown.SelectedIndex;

            _cbdropdown.Close();
            isActivated = false;
            this.Invalidate(true);
            _cbsystem.SelectedIndex = selectedindex;            // triggers _cbsystem_SelectedIndexChanged
            Focus();
        }
Exemple #3
0
 // Sometimes, the user is quicker than the timer, and has commited to a selection before the results even come back.
 public void AbortAutoComplete()
 {
     if (waitforautotimer.Enabled)
     {
         waitforautotimer.Stop();
     }
     else if (isActivated && _cbdropdown != null)
     {
         isActivated = false;
         _cbdropdown.Close();
         Invalidate(true);
     }
 }
Exemple #4
0
        private void _cbdropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedindex = _cbdropdown.SelectedIndex;

            _cbdropdown.Close();
            _cbsystem.SelectedIndex = selectedindex;
        }
        private void _cbdropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            int selectedindex = _cbdropdown.SelectedIndex;

            _cbdropdown.Close();
            isActivated = false;
            this.Invalidate(true);
            if (_cbsystem.SelectedIndex != selectedindex)
            {
                _cbsystem.SelectedIndex = selectedindex; // triggers _cbsystem_SelectedIndexChanged, but only if we change the index..
            }
            else
            {
                _cbsystem_SelectedIndexChanged(sender, e);      // otherwise, fire it off manually.. this is what the system box does, if the user clicks on it, fires it off
            }
            Focus();
        }