![]() |
| | #1 |
| Registered User Join Date: Oct 2008
Posts: 85
| Controlcollections Just used a control collection to parse all the textboxs on my form, and from what i can see it parse's in reverse order ?? is this correct ? is there anyway to make it follow the tab order or something so that it does it the right way round ? thanks |
| deviousdexter is offline | |
| | #2 |
| Registered User Join Date: Jun 2008
Posts: 1,285
| When you say parse, what code are you using? You use an enumarator? In that case it should start from the beginning, or one element before the beginning I think. The foreach should do the same thing. Never used a ControlCollection, so dunno for sure. But post the parsing code |
| C_ntua is offline | |
| | #3 |
| Registered User Join Date: Oct 2008
Posts: 85
| maybe parse was the wrong word to use in this case. basically when i use this piece of code it appears to start going through the controls in reverse order. there is a button and several text boxs that need checking and using the following seems to start at the button and work up the form. Code: Control.ControlCollection ctrls = this.Controls;
foreach (Control ctrl in ctrls)
{
if (ctrl.GetType() == typeof(TextBox) && ctrl.Text == "")
{
MessageBox.Show("Please complete all Information required!");
ctrl.Focus();
return;
}
}
|
| deviousdexter is offline | |
| | #4 |
| Registered User Join Date: Jun 2008
Posts: 1,285
| If you see the code generated you will see that there are lines like this.Controls.Add(...) or something like that. So you can change the order that the controls are added in the this.Controls list. That is the best thing to do |
| C_ntua is offline | |
| | #5 |
| Registered User Join Date: Oct 2008
Posts: 85
| thanks for that - i can see the problem - dont know why they have been added to the form in the wrong order maybe just the way the IDE deals with it |
| deviousdexter is offline | |
| | #6 |
| Registered User Join Date: Jun 2008
Posts: 1,285
| I believe they are added by the order you create them. Or your IDE has a weird way for ordering them (in which case slap it and show it who's boss) |
| C_ntua is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|