# Control Sets in API2.0

**URL:** <https://forum.xojo.com/t/control-sets-in-api2-0/83726>\
**Category:** General\
**Created:** [December 28, 2024, 6:31pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726 "2024-12-28T18:31:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 28, 2024, 6:31pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/1 "2024-12-28T18:31:56Z")

</div>

Did something change in API2.0 and the new DesktopUIControl classes and control sets? I’ve always done controls sets like this…

1.) Create your first control in the IDE and set it as a control set.  
2.) In code before you create any of your new controls, close that first item in the control set.  
3.) Create your new controls.

So let’s say you have a DesktopPopUpMenu call MyList and it’s a control set. In the opening event of the window, I could do this:

```auto
Sub Opening

MyList(0).Close

For i as integer = 0 to 5
   Dim mList as New MyList
   mList.top = 50+I*5
   mList.left = 20
Next

End Sub

```

I have this in a Window where I do this kind of code (but more complicated) but the Control Set is not created. I can create all the controls, add them to an array, etc. but the control set is closed and goes away when I call that first Close command. This appears to be different than the old controls as code that has worked fine for well over 10 years is now broken…

Thoughts?

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [December 28, 2024, 6:51pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/2 "2024-12-28T18:51:59Z")

</div>

Yes, they are there now.

- Add your first control to the window.
- Go to the Cog tag
- Select “New Control Set” from the Member of popup menu.

That control will be element 0 and you can add others to the set. They didn’t used to be there but they were put back some time ago.

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 28, 2024, 7:03pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/3 "2024-12-28T19:03:31Z")

</div>

I know they are there in the IDE. But I am creating them dynamically. That’s the code that seems to operate differently with the new controls.

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [December 28, 2024, 7:15pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/4 "2024-12-28T19:15:52Z")

</div>

If you create one control for the group does the rest then work?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 28, 2024, 7:21pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/5 "2024-12-28T19:21:28Z")

</div>

Jon does it help to know that you can embed controls dynamically without control sets in API 2?

[DesktopWindow.AddControl()](https://documentation.xojo.com/api/user_interface/desktop/desktopwindow.html#desktopwindow-addcontrol)

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 28, 2024, 7:28pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/6 "2024-12-28T19:28:28Z")

</div>

I did not know that! Thanks, Tim. That actually might be very useful.

And to answer Ian’s question - I can’t get it to work. As soon as I close the first control, it seems like subsequent controls are created just fine but not added to the control set.

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 29, 2024, 2:27pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/7 "2024-12-29T14:27:28Z")

</div>

Well, I think I see what my problem is here. I was trying to create API2.0 control sets on a legacy Window control. That does not work. I was hoping to be able to mix and match legacy controls and API2.0 controls together. Seems like you have to jump all in and convert everything. Maybe you don’t have to but I’ve got other windows that when opened/created have the original window as a property. So looks like everything has to go the new way or everything has to stay old…

---

<div class="post-metadata">

**Author:** ![AlbertoD](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/dbc845/32.png) [@AlbertoD](https://forum.xojo.com/u/AlbertoD)\
**Post date:** [December 29, 2024, 3:25pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/8 "2024-12-29T15:25:43Z")

</div>

> [@Jon\_Ogden](#):
>
> So looks like everything has to go the new way or everything has to stay old…

As I understand Xojo IDE is built using Xojo and Xojo staff said that not everything is API2.0 yet and that will take several years.

My guess is that, depending on what you are trying to do, you will need to convert at least some controls to API2.0 (a Window ‘can’t see’ Desktop controls, only a DesktopWindow, for example ControlCount will be 0 if the controls are Desktop controls on a regular Window).

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 29, 2024, 5:23pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/9 "2024-12-29T17:23:14Z")

</div>

It seems that while you can Add API2 controls to a classic Window, you cannot create API2 control sets on a classic window. The new controls you create just don’t show up!

---

<div class="post-metadata">

**Author:** ![Ian\_Kennedy](https://forum.xojo.com/user_avatar/forum.xojo.com/ian_kennedy/32/6860_2.png) [@Ian\_Kennedy](https://forum.xojo.com/u/Ian_Kennedy)\
**Post date:** [December 29, 2024, 11:17pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/10 "2024-12-29T23:17:50Z")

</div>

I’ve not checked for controls, however, you cannot have API 2 menus on a non API window or vice versa. I would stick with a window that is API 2 or API 1. That level of compatibility is certainly possible. You can use the IDE to convert a single window to API 2, which is helpful.

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 29, 2024, 11:33pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/11 "2024-12-29T23:33:58Z")

</div>

Yeah so I’ve discovered on that front as well. I saved a separate copy of my app and tried converting all of it. I might try it a window at a time too but given that I’ve had to update multiple sub-classes already I’m likely going to have to update most every window.

But is there any advantage to doing all this work?

---

<div class="post-metadata">

**Author:** ![Scott\_C](https://forum.xojo.com/user_avatar/forum.xojo.com/scott_c/32/19612_2.png) [@Scott\_C](https://forum.xojo.com/u/Scott_C)\
**Post date:** [December 30, 2024, 12:29am UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/12 "2024-12-30T00:29:43Z")

</div>

> [@Jon\_Ogden](#):
>
> But is there any advantage to doing all this work?

Unless I’m mis-remembering what I’ve read before, I think the main advantage of upgrading is the following:

- API-2 controls: Get new features, where applicable, and always get bug-fixes (when resources allow).

- API-1 controls: Generally, no new features or bug-fixes. In other words, given a lower priority.

Someone please correct me if I’m wrong, but generally that’s what I recall.

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [December 30, 2024, 8:59am UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/13 "2024-12-30T08:59:51Z")

</div>

You might want to read this and other similar threads.

> [@API1 to API2 conversion experience](https://forum.xojo.com/t/api1-to-api2-conversion-experience/67148):
>
> As I’ve no development I feel like doing on my app at the minute, I decided it was the time to attempt the conversion. A number of things have cropped up. Start with two copies of the project. One is for trying things, the other is for applying permanent conversion steps to. I have a number of small windows with only a few controls in each; these converted easily, with no compilation errors, and worked OK when tested. Such steps can then be applied to the clean copy. Having done that, SAVE! Thi…

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [December 31, 2024, 7:16am UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/14 "2024-12-31T07:16:39Z")

</div>

> [@Jon\_Ogden](#):
>
> But is there any advantage to doing all this work?

No, not for working code bases.

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 31, 2024, 4:28pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/15 "2024-12-31T16:28:03Z")

</div>

That’s what I figured.

Was hoping there would be some advantage but to me it seems like the DesktopControls are really a repackaging of the legacy controls. If you have an “Open” even in a window or control, the compiler will say that you tried to implement an event that the superclass has already implemented. So that tells me right there, that Xojo basically created a bunch of new subclasses and called them DesktopControls.

We shall see if the preemptive thread bug fixes get implemented on classic controls as well as the new ones. If they don’t then that would be a reason for me to continue this exercise. Until then, I think I’ll put it on hold…

---

<div class="post-metadata">

**Author:** ![Julia\_Truchsess](https://forum.xojo.com/user_avatar/forum.xojo.com/julia_truchsess/32/499_2.png) [@Julia\_Truchsess](https://forum.xojo.com/u/Julia_Truchsess)\
**Post date:** [December 31, 2024, 4:45pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/16 "2024-12-31T16:45:42Z")

</div>

> [@Tim\_Parnell](#):
>
> > [@Jon\_Ogden](#):
> >
> > But is there any advantage to doing all this work?
> 
> No, not for working code bases.

How practical is it to work on API1 projects with Xojo 2024? I’m a-scared it will sneakily and irrevocably convert my projects if I’m not super-vigilant. OTOH I wouldn’t mind enjoying some of the recent IDE improvements I’ve heard about.

---

<div class="post-metadata">

**Author:** ![TimStreater](https://forum.xojo.com/user_avatar/forum.xojo.com/timstreater/32/586_2.png) [@TimStreater](https://forum.xojo.com/u/TimStreater)\
**Post date:** [December 31, 2024, 10:30pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/17 "2024-12-31T22:30:53Z")

</div>

Even if you stick with API1 controls, nothing stops you using API2 database methods, which have the advantage that you get protection against SQL injection for nothing.

---

<div class="post-metadata">

**Author:** ![Jon\_Ogden](https://forum.xojo.com/user_avatar/forum.xojo.com/jon_ogden/32/494_2.png) [@Jon\_Ogden](https://forum.xojo.com/u/Jon_Ogden)\
**Post date:** [December 31, 2024, 10:48pm UTC](https://forum.xojo.com/t/control-sets-in-api2-0/83726/18 "2024-12-31T22:48:58Z")

</div>

Oh I’m already using a lot of those.

The most interesting part about the controls is how there was API2 for classic controls and then they changed it again for the new controls. Trying to look up the documentation for calls under API1 is a nightmare. Really annoying.
