Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
765
Subclass UltraTabPageControl ReadOnly Issues
posted

So I am subclassing UltraTabPageControl, called TabPageModified.  I had the following code:

public void AddTabToFinalList(TabPageModified tpm)

{

UltraTab addedTab = this.tabControl1.Tabs.Add(tpm.Text, tpm.Text);

addedTab.TabPage = tpm;

}

 But for some reason I get a runtime error that says that TabPage is read only and will not allow me to asign tpm to it.  However in another place in my code we do not have this issue and it runs fine.  In order to fix this I had to do this:

public void AddTabToFinalList(TabPageModified tpm)

{

UltraTab addedTab = new UltraTab();

addedTab.Key = tpm.Text;

addedTab.Text = tpm.Text;

addedTab.TabPage = tpm;

this.tabControl1.Tabs.Add(addedTab);

}

I'm glad to get it working but am rather perplexed.  Can you give any insight into why this is happening?

  • 44743
    Verified Answer
    posted

    The TabPage property can only be set when it has not been set already. Adding the tab to a TabControls's Tabs collection will assign a default TabPage to the tab and prevent you from supplying your own.  Try to set the TabPage property before adding the the tab to the control.