Select next control if control is in groupbox?
-
Hi all, I use the following code to select the next control.
private void opdrachtnummerTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ZakdataDatabase_Insert("Opdrachtnummer", opdrachtnummerTextBox.Text);
SelectNext_control(opdrachtnummerTextBox.Tag.ToString());} }
private void SelectNext_control(string t)
{
bool isNextControl = false;
int TagToFind = (int.Parse(t));
do
{
TagToFind++;
foreach (Control c in this.Controls)
{
if ((c.Tag != null)&&(c.Visible=true))
{
if (c.Tag.ToString() == TagToFind.ToString())
{
isNextControl = true;
c.Select();
}
}
}
if (TagToFind > 102) break;
} while (!isNextControl);
}All controls are tagged with an incremented number. What to do if the next control is in a groupBox? Thanks, Groover.
0200 A9 23 0202 8D 01 80 0205 00
-
Hi all, I use the following code to select the next control.
private void opdrachtnummerTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ZakdataDatabase_Insert("Opdrachtnummer", opdrachtnummerTextBox.Text);
SelectNext_control(opdrachtnummerTextBox.Tag.ToString());} }
private void SelectNext_control(string t)
{
bool isNextControl = false;
int TagToFind = (int.Parse(t));
do
{
TagToFind++;
foreach (Control c in this.Controls)
{
if ((c.Tag != null)&&(c.Visible=true))
{
if (c.Tag.ToString() == TagToFind.ToString())
{
isNextControl = true;
c.Select();
}
}
}
if (TagToFind > 102) break;
} while (!isNextControl);
}All controls are tagged with an incremented number. What to do if the next control is in a groupBox? Thanks, Groover.
0200 A9 23 0202 8D 01 80 0205 00
If it is in a groupbox, then you have to recursively search into each container control - which would also cover panels and so forth. But why not do it the easy way? Put the next control reference into the tag directly, instead of a number?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Hi all, I use the following code to select the next control.
private void opdrachtnummerTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ZakdataDatabase_Insert("Opdrachtnummer", opdrachtnummerTextBox.Text);
SelectNext_control(opdrachtnummerTextBox.Tag.ToString());} }
private void SelectNext_control(string t)
{
bool isNextControl = false;
int TagToFind = (int.Parse(t));
do
{
TagToFind++;
foreach (Control c in this.Controls)
{
if ((c.Tag != null)&&(c.Visible=true))
{
if (c.Tag.ToString() == TagToFind.ToString())
{
isNextControl = true;
c.Select();
}
}
}
if (TagToFind > 102) break;
} while (!isNextControl);
}All controls are tagged with an incremented number. What to do if the next control is in a groupBox? Thanks, Groover.
0200 A9 23 0202 8D 01 80 0205 00
-
If it is in a groupbox, then you have to recursively search into each container control - which would also cover panels and so forth. But why not do it the easy way? Put the next control reference into the tag directly, instead of a number?
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
To put the next control reference into the tag directly, instead of a number cannot be done because e.g the third control can be a listbox and the Visualibility property of other controls an groupBoxes depend on the selection in the listbox or checkboxes. Can I use the TabIndex instead? Thanks, Groover.
0200 A9 23 0202 8D 01 80 0205 00
-
Hi all, I use the following code to select the next control.
private void opdrachtnummerTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
ZakdataDatabase_Insert("Opdrachtnummer", opdrachtnummerTextBox.Text);
SelectNext_control(opdrachtnummerTextBox.Tag.ToString());} }
private void SelectNext_control(string t)
{
bool isNextControl = false;
int TagToFind = (int.Parse(t));
do
{
TagToFind++;
foreach (Control c in this.Controls)
{
if ((c.Tag != null)&&(c.Visible=true))
{
if (c.Tag.ToString() == TagToFind.ToString())
{
isNextControl = true;
c.Select();
}
}
}
if (TagToFind > 102) break;
} while (!isNextControl);
}All controls are tagged with an incremented number. What to do if the next control is in a groupBox? Thanks, Groover.
0200 A9 23 0202 8D 01 80 0205 00
I think we need some basic information here: 1. are all Controls in the GroupBox of the same Type ? If so, what Type ? If they are all the same type, why not just manipulate the TabIndex property, and let the Tab key do the work for you. 2. Have you considered the implications that a GroupBox has no 'TabStop property ? (hint: probably none !). Note that a Panel has a 'TabStop property. Run-time behavior (tabbing between Controls in a GroupBox will work as expected). 3. are Controls added at run-time to this GroupBox ? Since the last control added will have the highest TabIndex (and assuming TabStop set to 'true, and that it has a 'TabStop propery: what's the problem here. 4 issue of nested-containers as raised by OriginalGriff: if you have properly adjusted the TabIndex: I see no reason for a recursive descent here: tabbing from one Panel to another and, within the second Panel, "into a third Panel:" is no problem. So, I think to really understand if you have a unique problem here, we need to know much more about your UI structure, and the way you intend use of the Tab key to work. best, Bill
"If you shoot at mimes, should you use a silencer ?" Stephen Wright