System.Windows.Forms.ComboBox.Select C# (CSharp) Method

Select() public method

public Select ( int start, int length ) : void
start int
length int
return void
		public void Select (int start, int length)
		{
			if (start < 0)
				throw new ArgumentException ("Start cannot be less than zero");
			
			if (length < 0)
				throw new ArgumentException ("length cannot be less than zero");
			
			if (dropdown_style == ComboBoxStyle.DropDownList)
				return;
			
			textbox_ctrl.SelectionStart = start;
			textbox_ctrl.SelectionLength = length;
		}

Usage Example

        private void textEmp_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Up:
                if (comboBoxEmp.DroppedDown)
                {
                    textEmp.Leave -= new EventHandler(textEmp_Leave);
                    comboBoxEmp.Select();
                    comboBoxEmp.SelectedItem = comboBoxEmp.Items[comboBoxEmp.Items.Count - 1];
                    comboBoxEmp.FindForm().Cursor = Cursors.Default;
                    textEmp.Leave += new EventHandler(textEmp_Leave);
                }
                break;

            case Keys.Down:
                if (comboBoxEmp.DroppedDown)
                {
                    textEmp.Leave -= new EventHandler(textEmp_Leave);
                    comboBoxEmp.Select();
                    comboBoxEmp.SelectedItem = comboBoxEmp.Items[0];
                    comboBoxEmp.FindForm().Cursor = Cursors.Default;
                    textEmp.Leave += new EventHandler(textEmp_Leave);
                }
                break;
            }
        }
All Usage Examples Of System.Windows.Forms.ComboBox::Select