-
Extend Tabpage
Hi all!
I create a class named TabPageEx which extends TabPage.
In my app, sometimes it is necessary to get the selected tab from the TabControl ( I named this object as tcDataPanes) in order to add some controls.
I tried to cast from but it does not work.
Code:
tabpage1 = new TabPageEx();
tabpage1 = (TabPageEx)tcDataPanes.SelectedTab;
An InvalidCastExpection message appears at runtime.
All tabpages that were created are TabPageEx' type. Each tabPageEx object has a FlowLayoutPanel, and there is a method at TabPageEx which returns this container to my app.
What is wrong?
Thank you in advance!
-
Re: Extend Tabpage
-
Re: Extend Tabpage
This link was very helpful, wih it I solve some other problems which I had.
But, the problem which generates this thread persists.
This code line continues generating an InvalidCastExpection .
This is the class TabPageEx which I coded:
Code:
public class TabPageEx : System.Windows.Forms.TabPage {
FlowLayoutPanel flowLayoutPanel1;
public TabPageEx() : base () {
}
public TabPageEx(System.Windows.Forms.TabControl tcDataPanes) : base () {
tcDataPanes.TabPages.Add("New tab");
}
}
}
The situation that the error described in the first message occurs is when I try to retrieve the selected tab page in order to add a new control.
Any ideas? How can I solve it?
Thank you in advance!