# Adding Tabs with Dynamic Elements

**URL:** <https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541>\
**Category:** General\
**Created:** [September 9, 2015, 2:35pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541 "2015-09-09T14:35:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meade\_Lewis](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@Meade\_Lewis](https://forum.xojo.com/u/Meade_Lewis)\
**Post date:** [September 9, 2015, 2:35pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/1 "2015-09-09T14:35:23Z")

</div>

I am working on a project in which the user interface has many dynamic components where the controls are added as needed.

One group of these controls is being added into a tab panel. The issue is, when it is detected that there is no more space on the panel, it makes a new tab (I have that part working), but how do I make the new control be placed on the new tab? It seems that I can only get it to overlap the first element on the original tab.

Hopefully I am being clear enough and not too vague or confusing.

---

<div class="post-metadata">

**Author:** ![Joost\_Rongen](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/a9a28c/32.png) [@Joost\_Rongen](https://forum.xojo.com/u/Joost_Rongen)\
**Post date:** [September 9, 2015, 2:42pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/2 "2015-09-09T14:42:45Z")

</div>

Would it be an option to have a canvas on the form in which you can throw a containercontrol dynamic.  
It’s easy to make a scrolling form this way with a scrollbar etc.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [September 9, 2015, 2:57pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/3 "2015-09-09T14:57:57Z")

</div>

[quote=212440:@Meade Lewis]I am working on a project in which the user interface has many dynamic components where the controls are added as needed.

One group of these controls is being added into a tab panel. The issue is, when it is detected that there is no more space on the panel, it makes a new tab (I have that part working), but how do I make the new control be placed on the new tab? It seems that I can only get it to overlap the first element on the original tab.

Hopefully I am being clear enough and not too vague or confusing.[/quote]

You can specify the Tab in EmbedWithinPanel  
[http://documentation.xojo.com/index.php/ContainerControl.EmbedWithinPanel](http://documentation.xojo.com/index.php/ContainerControl.EmbedWithinPanel)

---

<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:** [September 9, 2015, 3:28pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/4 "2015-09-09T15:28:43Z")

</div>

How are you adding the controls? If a Control Set, you should also set the [PanelIndex](http://documentation.xojo.com/index.php/Control.PanelIndex) property for each new control.

---

<div class="post-metadata">

**Author:** ![Meade\_Lewis](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@Meade\_Lewis](https://forum.xojo.com/u/Meade_Lewis)\
**Post date:** [September 9, 2015, 5:49pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/5 "2015-09-09T17:49:37Z")

</div>

> [@212449:@Paul Lefebvre](#):
>
> How are you adding the controls? If a Control Set, you should also set the [PanelIndex](http://documentation.xojo.com/index.php/Control.PanelIndex) property for each new control.

I am doing the addition of the controls through a control set. My code looks like the following:

` if (((18*filecount)+FileRadioButton(0).top) + FileRadioButton(0).height) >= (FilesTabPanel.top + FilesTabPanel.Height) then
      FilesTabPanel.Insert(FilesTabPanel.Panelcount)
      FilesTabPanel.caption(FilesTabPanel.Panelcount-1) = str(FilesTabPanel.Panelcount)
      FirstonPage = true
      FilesTabPanel.Panelindex = FilesTabPanel.Panelcount
    end
    dim c as new FileRadioButton`

After this I state the location of the new radio button (c) as follows:

` if FirstonPage = true then
      c.Top = 58
      FirstonPage = False
    else
      c.top = (18*FileCount)+FileRadioButton(0).top
    end`

Why is it overlapping rather than going to the second tab?

Thanks!

---

<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:** [September 9, 2015, 5:55pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/6 "2015-09-09T17:55:23Z")

</div>

Looks like you need this somewhere:

```auto
c.PanelIndex = FilesTabPanel.PanelCount
```

You want to specify the PanelIndex for the newly added control.

---

<div class="post-metadata">

**Author:** ![Meade\_Lewis](https://forum.xojo.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@Meade\_Lewis](https://forum.xojo.com/u/Meade_Lewis)\
**Post date:** [September 9, 2015, 6:45pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/7 "2015-09-09T18:45:01Z")

</div>

[quote=212465:@Paul Lefebvre]Looks like you need this somewhere:

```auto
c.PanelIndex = FilesTabPanel.PanelCount
```

You want to specify the PanelIndex for the newly added control.[/quote]

The trick was that I had to do c.panelindex for the individual control, I was attempting to preform this with the tabpanel itself which got me nowhere.

As for your code, I had to edit it slightly:

```auto
c.PanelIndex = FilesTabPanel.PanelCount-1
```

Thank you so much!!!

---

<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:56pm UTC](https://forum.xojo.com/t/adding-tabs-with-dynamic-elements/26541/8 "2020-10-29T17:56:30Z")

</div>


