2

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?

One Monkey
  • 713
  • 3
  • 9
  • 24

1 Answers1

3

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.

AlaaL
  • 333
  • 9
  • 28
  • You, sir, are a champion. You learn something new every day. Like today I learned how stupid the way winforms, splitcontainer and control focus commands work together is. Many thanks. – One Monkey Apr 13 '11 at 09:03