How to step over the next control with GetNextControl(....,true).focus when the next control is not enabled
-
Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank
-
Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank
This assumes that you're starting from textBox1 and at least one textBox is enabled (even if only textBox1).
Control control = textBox1;
do
{
control = GetNextControl(control, true);
} while (!control.Enabled);
control.Focus();Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) -
Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank
Well, you could do something like this:
Control ctrl = GetNextControl(...);
if (ctrl.Enabled)
{
// ...do something...
ctrl.Focus();
}I haven't actually tried this, but some variation of it should work.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
Hi all, I have the problem to step over a disabled control with GetNextControl(...,true).Focus to the next enabled one. For example you have 3 textboxes with the tabindex 1,2,3 and a lot of other controls on the form. The focus is on the first textbox, the second one is disabled and I want to step to the third textbox with GetNextControl(...,true). The effect is, that GetNextControl(....,true) jumps to a control for example with tabindex=73 but not to the third one. What can I do to get the (correct) assumed reaction ? tnx Frank
Also you could perhaps simply use SelectNextControl[^] without a loop, like:
textBox1.SelectNextControl(textBox1, true, true, true, true)
The need to optimize rises from a bad design.My articles[^]
-
This assumes that you're starting from textBox1 and at least one textBox is enabled (even if only textBox1).
Control control = textBox1;
do
{
control = GetNextControl(control, true);
} while (!control.Enabled);
control.Focus();Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)