Search code examples
c#focussplitcontainer

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?


Solution

  • 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.