John
John

Reputation: 447

Change Focus to main Form

In my program, I click a button to go to a different form, and on the form it always focuses on a (read only) textbox (highlights its content).

How do I get it to focus on the form instead?

I've tried using .Focus() and ActiveControl.

Active Control worked, but I got an error that said "control not found", but then when I clicked "continue", it loaded up the form just fine, and didn't highlight the textbox...

Upvotes: 0

Views: 262

Answers (1)

Gabriel Negut
Gabriel Negut

Reputation: 13960

Set ActiveControl = null; in the Activated event of the form.

Upvotes: 1

Related Questions