I have a Problem, I dont know how I could remove controls, that I added by code to my Webapp.
I have a ContainerControl, which I add to another ContainerControl 10 or 15 times. Now I want to remove all ContainerControls.
I tested it with ControlAtID, ControlWithName and the other. I builded a for i = 0 to … loop, but I don’t find the right way.
Could you help me?
When adding your container controls to the webpage (in code), keep an array with references to those instances within the webpage. Then you simply loop through that array and call containercontrol.close
But ( it sounds a little bit stupid) where can I add the Array?
I am from VB.NET, there I could Add it over the code in the Class, but in Xojo?
In the navigator on the left, right-click on your webpage, select “Add To WebPageXYZ” and then “Property”
thank a lot!
There is no datatype “Array” in Xojo like in VB, but I can save alle types as arrays?!
Dim names() As String
names = Array("Fred", "Ginger", "Stanley")
I add the Controls over a loop into the Webpage (for i = 0 to whatever).
So I have to add the controls into the array also in the loop. But there’s no like Array.add(control). All controls I want to add must be known, when I add it to the array.
So, how can I add them, while I am doing the loop?
sorry for my english^^
Declare the property you just added to your webpage as follows: ThisIsAnArray() as MyWebContainer
The brackets indicate that this is an array of undefined size, fine for your purposes. Then in code, reference this array and append a container reference like this:
Yay! That works! last question:
how can I remove this controls yet?
This is my Code, but it do not work…
if not main.Zentrale_Aktuell.Ubound = 0 then
dim D as Post_normal
for each d in main.Zentrale_Aktuell
Zentrale_aktuell is my Array with all Containers
Zentrale is the Container, where I add all other containers
Main ist my Webpage
The documentary is not really good.
Take a look at the example I linked, I gave it an update. There’s a button that removes the controls.
Thank you very, very much!
It’s not really logical, how xojo in some details works, but anyway, it works!
For all user, here is the solution:
[quote] FOR i AS Integer = main.Zentrale_Aktuell.Ubound DOWNTO 0
What makes you believe it’s illogical? Maybe I can help you understand some bits and pieces.