Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parent/child controls

Status
Not open for further replies.

tobriain

Programmer
Jul 19, 2006
13
IE
I'm setting up a GUI to display data from an RTD server. I have a series of GroupBoxes with some textboxes to display the data that I'm creating in a 'for' loop.

The problem is that when I receive an update from the RTDServer, I want to be able to send the data straight back to the appropriate textbox, but I can't seem to be able to figure out how to do it.

If I do 'this.groupbox.textbox[j].text = topicvalue.toString()' or something similar, it doesn't like it. Will I have to cycle throught the groupboxes for 'i', then cycle through the textboxes for 'j' and then set the text? Or should I really have the data in some kind of DataGrid view or in an array?

Thanks in advance for any help.
 
Groupboxes are just for visually grouping other controls, they (usually) aren't used to provide a control hierarchy.

So to update your textbox, you'd just use it's name. Or... create a Dictionary object which maps your database column name to the textbox:
[tt]Dictionary<String, Textbox>[/tt]

A grid control might work, too.

Chip H.



____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Chip is right.

As far as your form and other controls are concerned, all textboxes and groupboxes and other controls are all accessible from within that form. The form dictates which controls are contained in other controls but all are equally accessible.
 
Thanks for your help, guys.

So if I was creating an array of groupboxes and an array of textboxes in each of them, that would explain why I could only reference the textboxes in the last created groupbox. So that idea is scrapped.

Would I be better off using some kind of dataList or DataGridView or something similar, if it turns out that i'll have quite a lot of textboxes and a lot of calculations to do on their values? Or would it be preferable to create an array, and send the RTD data directly to update the array? I can think of some elegant way to present it later. .

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top