Can you use Forms Designer to index controls?
-
Hi, I'm using Visual Studio 2005 C++/CLI. I have a data entry Form that has 50 TextBox controls. The Forms Designer gives these controls the names textBox1, textBox2,.....textBox50. When I check to make sure none of the fields are null I have to write code for each of the 50 controls. It would be nice if I could loop through textBox(n) controls. Is there any way to do this? Thanks Buck
-
Hi, I'm using Visual Studio 2005 C++/CLI. I have a data entry Form that has 50 TextBox controls. The Forms Designer gives these controls the names textBox1, textBox2,.....textBox50. When I check to make sure none of the fields are null I have to write code for each of the 50 controls. It would be nice if I could loop through textBox(n) controls. Is there any way to do this? Thanks Buck
I don't do any forms coding, but can you iterate through the control collection for the form and look for TextBox controls? Something like:
for each (Control control in form->Controls)
{
if (nullptr != dynamic_cast<textbox>(control))
{
...
}
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Tuesday, June 17, 2008 6:25 PM
-
Hi, I'm using Visual Studio 2005 C++/CLI. I have a data entry Form that has 50 TextBox controls. The Forms Designer gives these controls the names textBox1, textBox2,.....textBox50. When I check to make sure none of the fields are null I have to write code for each of the 50 controls. It would be nice if I could loop through textBox(n) controls. Is there any way to do this? Thanks Buck
BuckBrown wrote:
I have a data entry Form that has 50 TextBox controls.
BuckBrown wrote:
It would be nice if I could loop through textBox(n) controls.
Ok, but wouldn't it be better if you didn't have 50 textbox controls that you had to loop through? Alternative User Interface designs could eliminate that and simultaneously offer a better experience for the user.
led mike
-
I don't do any forms coding, but can you iterate through the control collection for the form and look for TextBox controls? Something like:
for each (Control control in form->Controls)
{
if (nullptr != dynamic_cast<textbox>(control))
{
...
}
}Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Tuesday, June 17, 2008 6:25 PM
-
LMAO did you see my post got voted a '1'? This place is really starting to suck dude.
led mike
Yeah :sigh: I try to ignore all the voting stuff, but I do notice stupid stuff like that.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Yeah :sigh: I try to ignore all the voting stuff, but I do notice stupid stuff like that.
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Fuck um, I'm going to start voting all the idiot questions a '1', I'm on a mission.
led mike
Well you've got your work cut out for you ;)
Mark Salsbery Microsoft MVP - Visual C++ :java: