# code; no workie, workie for creating a dynamic control

**URL:** <https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286>\
**Category:** Web\
**Created:** [August 14, 2013, 3:10am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286 "2013-08-14T03:10:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffery\_Nuxoll](https://forum.xojo.com/user_avatar/forum.xojo.com/jeffery_nuxoll/32/3856_2.png) [@Jeffery\_Nuxoll](https://forum.xojo.com/u/Jeffery_Nuxoll)\
**Post date:** [August 14, 2013, 3:10am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/1 "2013-08-14T03:10:45Z")

</div>

I’m trying to create several dynamic controls with in a Webcontainer.  
The Code takes an object that has been already created on the Webcontainer ( by dragging and dropping from the IDE), and then tries to copy that object x number of times.  
The Code works, kinda sort of, it only duplicates the object once.

The object is a ‘Super’ of the webimageview class

any idea on what I’m doing wrong??? Other than it doesn’t work 🙂  
I’m on 2012 R2.1  
Thanks to all who help!

```auto
  if session.opend = false then //opend is a method in session, that connects to a DB
    //TODO: display error
  elseif Session.opend = true then
    session.SQL = "SELECT Test.menuName, Test.menuPKI FROM test"
    session.rs = session.db.SQLSelect(session.SQL) // "rs" property in session of Recordset
   //TODO: db error checking    

    dim x as integer // to shift Dynamic control left by 112
    x = 9 // start with 9

    for i as integer = 0 to session.rs.RecordCount
      if session.rs.EOF() then //EOF = true , exit out
        return
      end
      
      msgbox(session.rs.Field("menuName")) //Msgbox Display's the field correctly on every pass
      
      // ----- Code below; Trying to duplicate an already existing object in the WebContainer --
      //----- Only displays the object, once
      // ----- Tried the code with a normal webimageview, same results
      dim dynamicControl as new myImageviewClass
      dynamicControl = myImageviewClass1
      dynamicControl.Left = x
      dynamicControl.top = 32
      dynamicControl.Visible = true
      dynamicControl.Enabled = true
      
      x = x + 112 //shifting by 112 every iteration of the FOR/NEXT
      session.rs.MoveNext
    next
    
  end
  
```

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [August 14, 2013, 3:14am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/2 "2013-08-14T03:14:20Z")

</div>

dont try to copy an existing control on the WebPage. Create a new one from scratch like this:

`dim w as new myImageViewClass
w.embedWithin(self,x,32,w.width,w.height)`

---

<div class="post-metadata">

**Author:** ![Jeffery\_Nuxoll](https://forum.xojo.com/user_avatar/forum.xojo.com/jeffery_nuxoll/32/3856_2.png) [@Jeffery\_Nuxoll](https://forum.xojo.com/u/Jeffery_Nuxoll)\
**Post date:** [August 14, 2013, 3:24am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/3 "2013-08-14T03:24:29Z")

</div>

Hi Greg, thank you for your quick reply

can you do an ‘embedWithin’ within a WebContainer control?

I understand what you are trying to tell me, and yes that would work with a webpage.

none the less, thank you for the reply!

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [August 15, 2013, 7:06am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/4 "2013-08-15T07:06:18Z")

</div>

Yes.

---

<div class="post-metadata">

**Author:** ![Jury\_Buono](https://forum.xojo.com/user_avatar/forum.xojo.com/jury_buono/32/3074_2.png) [@Jury\_Buono](https://forum.xojo.com/u/Jury_Buono)\
**Post date:** [February 15, 2014, 9:35am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/5 "2014-02-15T09:35:09Z")

</div>

Hi Greg, i don’t understand.  
i have try to create e new WebContainer (name wcA)  
how can i dynamically add a lot of webTextBox to wcA ???  
i have tried to :

put webTextBox (name wTxt1) in wcA (webContainer) then i write this code in wcA.open event  
dim newTxt as new wTxt1  
newTxt.embedWithin(self,10,32,100,100)  
but this produce an error

then i have tried to made a class with super WebTextField named txtClass1  
in wcA.open i have put this code  
dim newTxt as new txtClass1  
newTxt.embedWithin(self,10,32,100,100)  
but this produce another error

i don’t understand how can i dynamically add controls to webContainer …  
can you help me please ?  
thank you j.b.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [February 16, 2014, 4:59am UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/6 "2014-02-16T04:59:49Z")

</div>

Create a WebContainer subclass that has the control in it that you want to add dynamically. Then in code, create an instance and call EmbedWithin on that.

---

<div class="post-metadata">

**Author:** ![Jury\_Buono](https://forum.xojo.com/user_avatar/forum.xojo.com/jury_buono/32/3074_2.png) [@Jury\_Buono](https://forum.xojo.com/u/Jury_Buono)\
**Post date:** [February 20, 2014, 2:23pm UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/7 "2014-02-20T14:23:29Z")

</div>

ok i have tryed and it is ok, tnx Greg

---

<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, 4:48pm UTC](https://forum.xojo.com/t/code-no-workie-workie-for-creating-a-dynamic-control/10286/8 "2020-10-29T16:48:20Z")

</div>


