0

I am creating a primitive library search Windows Forms App(.NET Framework) in Visual Studio and when I run it the comboBox on the right is selected so that when the user begins typing the text is entered in the comboBox not the (Search) text box. What it looks like immediately upon running: When I type something it is entered in the left comboBox.

How do I make it so that when the app starts the text box is selected by default so that the user does not have to click on the text box before typing in their search? Also, how do I change the comboBoxes so that they do not accept user input? Thanks.

Nick Knapp
  • 23
  • 5
  • See the [Control.TabIndex](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.control.tabindex) property. Set it to `0` in the TextBox control and to `1` (or `1`, `2`) in the others. When the Form is loaded, the selectable control with the lowest TabIndex will receive the focus. You can set [`ComboBox.DropDownStyle`](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.combobox.dropdownstyle) `= ComboBoxStyle.DropDownList` to make it non-editable. – Jimi Nov 25 '19 at 02:07

1 Answers1

1
namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.ActiveControl = textBox2; // <--- set the active control
        }
    }
}

How to make Combobox in winforms readonly check the second answer

Dave
  • 120
  • 1
  • 10