I have created controls at Runtime using ControlSets in the past. Now the documentation tells me that I can create a control at runtime. How is this done? I can find the documentation describing how to do it using Control Sets but what is this better way to do it? I have not found the documentation for creating a Control at Runtime without using a ControlSet
From the documentation:
Control Sets are no longer needed because you can now create controls at runtime and add them to the layout for all project types. It is suggested that you do that rather than use Control Sets.
I have tried various things with no success. One, just to prove I have tried, was to have a property of a window be oneRect and in the code of the Opening event of the window
I had hoped that there would be a rectangle on the window when it appeared but nothing. Various others things I tried did not work. So what is the way that you code a Control to appear at runtime?
KColor.BLACK and KColor.BLUEBERRY are just constants that I have in my code.
I credit Adam with the solution because he was first but I appreciate the next two posters as well for additional information. All appreciated.
I do like the references to the blog pages. I would comment that in its current state, this information is hard (? impossible) to find in the regular documentation for Desktop. Where the current documentation comments that ControlSets are not necessary, it would be nice to have it go further and link you to a page or explain the AddControl command for Desktop.
That is a totally gratuitous and ridiculous statement which should be removed from the documentation. Control Sets are quite useful completely apart from the question of whether they are created at runtime or not.
It smacks of a programmer who’s all excited about having created something and now feels compelled to insist on everyone else’s use of it.
That has been my major use of them over the years as well… I had perviously commented on how misguided that statement in the docs is IMO in another thread…
When I first saw it I worried that they might be headed towards deprecating control sets.