Hello I am a currently learning C# and added this to my code
InitializeComponent();
this.ActiveControl = txtUsername;
txtUsername.Focus();
What does do and what does this.ActiveControl .Focusdo and whats the difference
Thank you for your time
Hello I am a currently learning C# and added this to my code
InitializeComponent();
this.ActiveControl = txtUsername;
txtUsername.Focus();
What does do and what does this.ActiveControl .Focusdo and whats the difference
Thank you for your time
They can both do the same thing effectively. One requires a visible element while the other does not. This can be used to place cursor input on txtUsername when the form appears.
this.ActiveControl = txtUsername;
This will do the same thing if the txtUsername control is visible.
txtUsername.Focus();
The key is that the element must be visible in order for the Focus() method to work. See this for further information.