How to set focus to a control in a Windows Forms application?

By far the simplest solution is to set the TabIndex property correctly so that your ‘MyDropDownList’ control has the lowest index. The next approach is to do it in the constructor. But you have to use Select(), the Focus() method cannot work yet because the control doesn’t become visible until later.

Public Sub New()
    InitializeComponent()
    MyDropDownList.Select()
End Sub

Works in the Load event as well. Focus() starts working in the Shown event.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)