GetNextControl - How to use???

When I Enter a particular control on a WinForm, I need to know the previous control. I have the following code:

private void txtFirstNames_Enter(object sender, System.EventArgs e)
    Control currCtl = (Control)sender;  //current control
    Control prevCtl = currCtl.GetNextControl(currCtl, false)   //previous control

The problem with the above code is that prevCtl = null after executing the line.

According to the Microsoft docs (which are totally inadequate - with NO code examples), the format of the GetNextControl method is:

   Control ctl, //control to start searching from
   boolean direction  //false - go back; true - go forward

What am I doing wrong???? A code snippet will help as well as an explanation of why my code is not working. I'm sure it's something simple.


PS: sorry for the low points, but that's all I have left!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can't call GetnextControl on the Control which doesn't have childs controls, you shoud try to change:
Control prevCtl = currCtl.GetNextControl(currCtl, false)   //previous control

in somthing like this Control prevCtl = ActiveForm.GetNextControl(currCtl, false)  

because both controls are child controls of a form!


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
An alternative (if you're not using controls as direct children of the form) is to use:
Control prevCtl = currCtl.Parent.GetNextControl(currCtl, false)   //previous control
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.