简体   繁体   中英

Control no longer gaining focus after putting it in a splitcontainer

I have a forms app and when it starts up I would like it to give focus to a particular text box. While I was initially developing I just whacked all the controls straight on the form and the focus command worked fine.

The app is near ready and I put some splitcontainers on the form just to hold the controls in neatly defined areas using their Dock properties. Now a completely different read only control gets focus on startup and the app seems to ignore my command that the focus should go to this one textbox. Does any one know why this might be?

You can try this :

splitContainer1.Focus();
splitContainer1.ActiveControl = textBox1;

If it doesn't works please post your focus code here. Sorry because i didn't write a comment but i don't have the privilege yet.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM