Im using C# and Winforms and have a UI consisting of some usercontrols. Some of the user controls are disabled and are only enabled when certain criteria are met. The problem Im having is that when I am on the last nested control of a user control and i hit tab I want to be able to validate that set of criteria and if true enable the next User control and go to its first nested control.
Seems like a very straight forward and simple thing to do.
Now i know that tab key wont fire certain keypress events so Ive tried validating;validated;leave etc but although the next user control is enabled the focus always goes to the control after the "next" usercontrol in this case the cancel button. Then you've got to shift tab back to the previous user control to input.
The tab orders are set correctly and Im also using focus code. So ive tried:
if (this.OrderReceievedFromIsSet && this.OrderReceivedViaIsSet)
{
this.tabOrderDetail.Enabled = true;
this.txtComment.Enabled = true;
this.pageOrderDetail.Focus();
}
Ive also tried
this.ActiveControl = this.pageOrderDetail
There are no other events pulling focus so I dont what the problem is. Its as if the tab event is storing the next target focus control then firing these event, which set focus, then using the stored next target focus control anyway.
Either way Im not getting the result that I want which is to simply enable and step into the next user control and focus its first nested control if previous input is valid.