How to keep cursor within the scope of a custom user control ??

  • Thread starter Thread starter BBFrost
  • Start date Start date
B

BBFrost

We have a data entry application written within Framework 1.0 that contains
20+ custom user controls.

The controls overlay each other so that only one custom control is visible
at a time. What is the best way to keep the cursor from jumping to another
non-visible control when the user tabs past the (currently designated) last
control on the form. I've had some luck using the Leave event but the last
visible control can change depending on the state of the user control within
question.

Nothing seems to work consistently to keep the cursor within the bounds of
the user control.

Any suggestions would be GREATLY appreciated.

Thanks in advance.

Barry
in Oregon
 
Hi Barry,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to prevent cursor from
stopping on non-visible controls. If there is any misunderstanding, please
feel free to let me know.

Based on my experience, each user control will have a property named
TabStop. If this property is set to true, the cursor will stop on this
control when press tab key. So if you don't need to cursor to stop, we just
need to set this property to false on the invisible controls.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Kevin,

Thanks for the prompt reply. It's very much appreciated (unfortunately I
was out of the office on Friday).

Hummm, interesting.

I believe I'll need to set up an array of hosted user controls to do this,
however, if your suggestion works it'll be worth the trouble. It may take
a bit before I get this implemented but I'll make a point to echo the
results to the group.

Thanks again.

Barry
in Oregon
 
Kevin,

I finally applied this solution in an application that contained 3 custom
user controls layered on top of each other on a main from (frmMain).

I created a frmMain ArrayList of the user controls hosted by frmMain.

When one of the controls was selected by the user I passed the ArrayList
setting the UserControl.TabStop = false for all except the control that
was selected.

This worked partially in that it keep the cursor from jumping to the
unselcted user controls (overlayed in the z-order) by the selected control.

Unfortunately, the cursor still jumped from the selected user control to
frmMain when I tabbed past the last (tab index) textbox on the user control.

I tried setting the frmMain.TabStop = false but the cursor still jumped to
exposed (non-custom user) controls on the frmMain.

Finally to keep the cursor restricted to the selected user control. I had
to
set the TabStop = false for ALL controls (multiple buttons, textboxs, etc)
contained on the frmMain, not just the user controls.

This makes sense in that controls are controls but it makes cursor
management within a large complex application a real PIA. Since
my users want the cursor to stay within the selected user control until
they click on the main form. Once they click on the main form they
want to use the Tab Key to bounce around on the main form.

Anyway, thanks for your help in getting this far. It is very much
appreciated.

Barry
in Oregon
 
You're welcome, Barry.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top