kranthi4uonly
asked on
AUTO TABING PROPERTY IN WINDOWS FORM WITHOUT HITTING THE TAB KEY ANY ONE PLEASE HELP ME
i want to tab through all the controls in the windows form like for example if i say if the maximum sieze of a text box is reached it should go to next control and to next control like check box once it is checked next to drop down list next to other controls liek tht can any one please help me out
ASKER
like i cant see the "IDontWantToLeave" in the inteliisense in vs 2005 can u help me with this please
ASKER
and also i cant see "IDOWANTTOLEAVE"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi david thnaks for ur help but iam a fresher recently i started with .net can u please give the whole code please i had tried but this is not going to next control can uplease give me the code please
For TextBoxes, I used KeyPress and Leave handlers. In Keypress, I do my special stuff, set e.Handled true, then call SelectNextControl((Control
In <controlname>JointExit(), I set the reentrancy flag, do my stuff, and if I want to tab ahead and I am NOT leaving already, I call SelectNextControl((Control
I call the joint exit routine from other controls, and when I do, I set the leaving flag false, so that the autocomplete stuff happens.
I'm sure this was obtuse... For textboxes, I do a similar thing. Here is some example code where a checkbox interacts with a textbox:
[Code]
private void countyMonthsCheckBox_Leave
{
if (inCountyTimeJointExit == false)
countyTimeJointExit(sender
}
private void countyMonthsCheckBox_Check
{
if (inCountyTimeJointExit == false)
countyTimeJointExit(sender
}
private void countyTimeTextBox_Leave(ob
{
if (inCountyTimeJointExit == false)
countyTimeJointExit(sender
}
bool inCountyTimeJointExit = false;
private void countyTimeJointExit(object
{
try
{
inCountyTimeJointExit = true;
<yada, yada>
if (leaving && IDontWantToLeave )
((Control) sender).Focus();
else
SelectNextControl((Control
if (!leaving && IDoWantToLeave)
SelectNextControl((Control
}
finally
{
inCountyTimeJointExit = false;
}
}
[/Code]
You get the idea.... Cover both "leave" events and the autocomplete event ("keyup" for textboxes, "selectedindexchanged" for comboboxes, "checkchanged" for checkboxes. Use a JointExit routine with a "leaving" flag. Protect that routine with a reentrancy flag. (This is needed since when the joint routine changes focus , you don't want it to be called again) Also, in that routine, select the next control if not leaving already. Or, select the current control if you are leaving and you don't want to.
This code worked great - the operators loved not having all of the extra tabbing and having autocomplete. It was developed for 1.1, and some things might be easier to do now in 2.0. However, this code still works.
David