# Managing many controls

**URL:** <https://forum.xojo.com/t/managing-many-controls/16651>\
**Category:** Getting Started\
**Created:** [May 20, 2014, 3:02pm UTC](https://forum.xojo.com/t/managing-many-controls/16651 "2014-05-20T15:02:41Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frank\_Spillman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/f/b5e925/32.png) [@Frank\_Spillman](https://forum.xojo.com/u/Frank_Spillman)\
**Post date:** [May 20, 2014, 3:02pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/1 "2014-05-20T15:02:41Z")

</div>

I am converting a Visual Basic project whose screen has a great many controls on it. There are buttons, text boxes, and labels. These are necessary to manage the display of a graph plot and summarize certain details of the data. There may be 40 or 50 all told. This means that the control list in the IDE is very long, and every time there’s a program break, all of the controls are expanded and I have to scroll through a long list to find what I need. I don’t seem to be able to insert a Folder within the Controls section, so I could (for example) group and conceal all the Labels.

Is this correct? Is there any way to compartmentalize a big list of Controls into subsections?

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [May 20, 2014, 3:05pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/2 "2014-05-20T15:05:23Z")

</div>

Convert them to CONTROL SETS (where appropriate), then the IDE will automatically group those  
This will require you code to be altered… but it is probably best to refactor it this way if you have so many controls.  
Each Control Set would contain those controls that are “similar” in function.

FYI… This was a concept that VB supported as well, I just don’t recall what they called it.

---

<div class="post-metadata">

**Author:** ![Paul\_Lefebvre](https://forum.xojo.com/user_avatar/forum.xojo.com/paul_lefebvre/32/3152_2.png) [@Paul\_Lefebvre](https://forum.xojo.com/u/Paul_Lefebvre)\
**Post date:** [May 20, 2014, 3:13pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/3 "2014-05-20T15:13:49Z")

</div>

ContainerControls are also a great way to create subsections of your UI layout that you can then combine on the Window.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [May 20, 2014, 3:14pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/4 "2014-05-20T15:14:21Z")

</div>

We tend to use Container Controls. Generally controls are grouped into logical function so it makes sense, to us at least, to do it this way. So each container has it’s own load/save/validate methods.

That way the parent window/container doesn’t really need to know about the individual controls. We find this results in much cleaner code and the IDE Navigator doesn’t get clogged with a bajillion (the technical term) controls that you generally don’t need to deal with on a regular basis.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [May 20, 2014, 3:19pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/5 "2014-05-20T15:19:04Z")

</div>

> [@89750:@Dave S](#):
>
> Convert them to CONTROL SETS

To each their own, but control sets, or control arrays if you will, tend to cause issues from our experience. You spend more time worried about their index then you do about their function. My other beef with them is that unless you use constants for the index you can’t tell what the function of the control is by looking at the name in code.

Example:  
TextField1(0).text = “”  
TextField1(1).text = “”  
TextField1(2).text = “”

is bad. This is slightly better:

TextField1(kFirstName).text = “”  
TextField1(kLastName).text = “”  
TextField1(kAddress).text = “”

but still more complicated than just using properly named controls

txtFirstName.text = “”  
txtLastName.text = “”  
txtAddress.text = “”

Yes, it’s more work, but it’s way more readable. Again, not trying to start a flame war but we err on the side of ease of understanding.

---

<div class="post-metadata">

**Author:** ![Louis\_D](https://forum.xojo.com/letter_avatar_proxy/v4/letter/l/cab0a1/32.png) [@Louis\_D](https://forum.xojo.com/u/Louis_D)\
**Post date:** [May 20, 2014, 3:25pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/6 "2014-05-20T15:25:58Z")

</div>

Control sets can be useful where you have many of the “same” controls. Imagine for example a sales order screen. You will have many item lines, each with a quantity field, a material number field, a description field, a price field, etc. Control sets could be used here, where the index corresponds to the item line. Control sets should not be used to group controls that have different purposes. (as Bob’s example shows)

---

<div class="post-metadata">

**Author:** ![Merv\_Pate](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Merv\_Pate](https://forum.xojo.com/u/Merv_Pate)\
**Post date:** [May 20, 2014, 3:48pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/7 "2014-05-20T15:48:42Z")

</div>

> [@89756:@Bob Keeney](#):
>
> txtFirstName.text = “”

Yes, certainly more readable, but in VB6 there control sets used less resources, and that was a big deal under earlier versions of Windows (where many VB6 programs got there start). Some of my screens in Xojo have control sets for the simple reason, that is how it was in the original VB6 program I converted. Is naming them their own individual name not a resource issue that you have to think about in Xojo?

---

<div class="post-metadata">

**Author:** ![Jim\_Smith](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@Jim\_Smith](https://forum.xojo.com/u/Jim_Smith)\
**Post date:** [May 20, 2014, 3:56pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/8 "2014-05-20T15:56:29Z")

</div>

Question. In Bob’s example, as below:

`Example:
TextField1(0).text = ""
TextField1(1).text = ""
TextField1(2).text = ""`

If TextField1(0) is changed from just First Name to Name, and TextField1(1) is deleted. Does TextField1(2) become TextField1(1) or what?

(I’m a LOW level machine-assembly language guy).

---

<div class="post-metadata">

**Author:** ![DaveS](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/848f3c/32.png) [@DaveS](https://forum.xojo.com/u/DaveS)\
**Post date:** [May 20, 2014, 4:46pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/9 "2014-05-20T16:46:15Z")

</div>

[quote=89764:@Jim Smith]Question. In Bob’s example, as below:

`Example:
TextField1(0).text = ""
TextField1(1).text = ""
TextField1(2).text = ""`

If TextField1(0) is changed from just First Name to Name, and TextField1(1) is deleted. Does TextField1(2) become TextField1(1) or what?

(I’m a LOW level machine-assembly language guy).[/quote]

No… once created they maintain their assigned “index”, unless you manually change them

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [May 20, 2014, 5:27pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/10 "2014-05-20T17:27:52Z")

</div>

> [@89761:@Merv Pate](#):
>
> Is naming them their own individual name not a resource issue that you have to think about in Xojo?

There probably is some upper limit but I’ve never come across it. The more controls you have onscreen the slower the layout editor is and I don’t think that control sets change that much (but I am willing to be wrong on that one).

I worked on one project (in Real Studio not Xojo) that was a VB6 conversion. It was a one window app that had something in the neighborhood of 1200 controls between all the various tabs and page panels. It was a nightmare in VB6 and I doubt the damn thing ever really worked right. In Real Studio, those 1200 controls got split out to 20 or so major containers and perhaps another 10-15 smaller containers and the layout editor didn’t even blink.

The parent window never had to load/save from the individual controls since the containers handled that. It encapsulated the UI beautifully by function and, when adding ActiveRecord into the mix, the project took no time at all. And the code was very readable and simple to update. The hardest part was reading the VB6 code to convert it to RB. They used control arrays with no constants, and they used default control names. I probably spent more time fixing the VB6 code so it was readable than I did in Real Studio.

Just my two cents worth. I’ve converted a lot of VB6 projects.

---

<div class="post-metadata">

**Author:** ![Merv\_Pate](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Merv\_Pate](https://forum.xojo.com/u/Merv_Pate)\
**Post date:** [May 20, 2014, 5:34pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/11 "2014-05-20T17:34:58Z")

</div>

I have nothing along that order of magnitude, so I think I will change the names. It does get old trying to remember which field CustomerDetail(4).Text is.

I’ve been encapsulating controls on a canvas because the canvas attaches to a window splitter so easily, and this setup really smoothes out the redrawing of a screen. It doesn’t help with the flicker much when moving/resizing windows, but it does help the whole screen redraw at once making it appear a smoother transition when switching from screen to screen, much more like it does on the Mac. Without them, I’m always having issues with different ListBoxes popping up at slightly different speeds depending on what was loaded from the DB. I’ll have a look at the container controls again and see if it is a better solution. Thanks for the tip.

---

<div class="post-metadata">

**Author:** ![Simon\_Berridge](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/cc9497/32.png) [@Simon\_Berridge](https://forum.xojo.com/u/Simon_Berridge)\
**Post date:** [May 20, 2014, 10:23pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/12 "2014-05-20T22:23:12Z")

</div>

Container Controls are definitely the way to go.

Logically group your on-screen controls into different containers and place them on the main window. These will attach nicely to splitter controls and they are _much_ easier to handle and maintain than canvas controls.

---

<div class="post-metadata">

**Author:** ![Gavin\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gavin_smith/32/13901_2.png) [@Gavin\_Smith](https://forum.xojo.com/u/Gavin_Smith)\
**Post date:** [May 20, 2014, 10:51pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/13 "2014-05-20T22:51:21Z")

</div>

I concur that Container Controls are the way to go here.

Each to their own, but I wouldn’t use Control Sets for the sole intention of cleaning up the Navigator, unless I had lots of labels that I was never going to reference in code.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 20, 2014, 11:08pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/14 "2014-05-20T23:08:24Z")

</div>

> [@89761:@Merv Pate](#):
>
> Yes, certainly more readable, but in VB6 there control sets used less resources, and that was a big deal under earlier versions of Windows (where many VB6 programs got there start). Some of my screens in Xojo have control sets for the simple reason, that is how it was in the original VB6 program I converted. Is naming them their own individual name not a resource issue that you have to think about in Xojo?

Not like it was in VB

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 20, 2014, 11:10pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/15 "2014-05-20T23:10:10Z")

</div>

[quote=89796:@Merv Pate]I have nothing along that order of magnitude, so I think I will change the names. It does get old trying to remember which field CustomerDetail(4).Text is.  
[/quote]  
Hence Bob’s other recommendation IF you DO use controls sets define constants so you get

CustomerDetail(kLastName).Text

so you don’t have to remember that CustomerDetail(4).Text is the last name

---

<div class="post-metadata">

**Author:** ![Merv\_Pate](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@Merv\_Pate](https://forum.xojo.com/u/Merv_Pate)\
**Post date:** [May 20, 2014, 11:13pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/16 "2014-05-20T23:13:00Z")

</div>

> [@89921:@Norman Palardy](#):
>
> so you don’t have to remember that CustomerDetail(4).Text is the last name

Thanks. I think I am just going to remove the control sets on some of the screens. Really no reason for it other than it was that way in VB when I converted the program 4 years ago.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:14pm UTC](https://forum.xojo.com/t/managing-many-controls/16651/17 "2020-10-29T17:14:04Z")

</div>


