How to move a control to another tab programmatically in C#?

949 views Asked by At

I have a TabControl which contains some tabs. each tab includes a Word component control which loads Microsoft office word. Every time User opens a new tab, a new Word component control has to be add to it which takes a little time. Is there a way to move the current Word component control to the new tab programmatically when adding new tabs, so it doesn't have to create a new component class?

Something like this (But Tabs[1] has no Controls)

stcWordTab.Tabs[1].Controls.Add(stcWordTab.Tabs[0].Controls[0])

EDIT

I'm using DotNetBar's SuperTabItem control.

1

There are 1 answers

2
Andrey Korneyev On

While Tab itself does not has Controls property, it has TabItem.AttachedControl property which is TabControlPanel connected to the tab and this panel hosts your controls.

So your code could looks like

(stcWordTab.Tabs[1].AttachedControl as TabControlPanel).Controls
    .Add((stcWordTab.Tabs[0].AttachedControl as TabControlPanel).Controls[0]);

See knowledge base for reference.