I have tried following method, but it didn't work at all, current focus stays on the very first textbox to whom i have set as TabIndex 0 through UI :-
private void OnFormLoad(object sender, EventArgs e)
{
txtServername.Text = Properties.Settings.Default.LastServerName;
txtDatabase.Text = Properties.Settings.Default.LastDatabase;
txtUsername.Text = Properties.Settings.Default.LastUserName;
if (!String.IsNullOrWhiteSpace(txtServername.Text))
txtDatabase.SelectNextControl(ActiveControl, false, true, true, true);
if (!String.IsNullOrWhiteSpace(txtDatabase.Text))
txtUsername.SelectNextControl(ActiveControl, false, true, true, true);
if (!String.IsNullOrWhiteSpace(txtUsername.Text))
txtPassword.SelectNextControl(ActiveControl, false, true, true, true);
}
Could someone please suggest a solution to above problem?
Use this method
textBox.Select();
Tested at my side, so i think it should work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.