Hi Mac,
[color=blue]
> I managed to get around the error by not actually casting but drectly
> assigning instance of MyTabPage = Current TabPage (in the collection).[/color]
Isn't that raise a compile-time error?
[color=blue]
>But looking at the base tabpage definition I realised what you mentioned Thi -
>the collection I loop through is a collection of TabPages not of MyTabPage.
>So what I assume is happening even though I create a new MyTabPage and set
>the properties, they are lost when I add it to a collection of TabPages.[/color]
No, nothing is lost. Maybe the VS.NET designer adds some tab pages for
you? And it add TabPage instead of MyTabPage.
If you only add instances of MyTabPage to your collection, it should
work.
[color=blue]
>Is there an easy way to create a collection in a TabControl that holds a
>derived class of TabPage? The Add function for the TabPageCollection is not
>overiddable so I assume this is not possible.[/color]
The Add function takes a param of type TabPage and that is good. You
don't need to override it. Just call TabPageCollection.Add(new
MyTabPage()). You might want to search your code, especially the code
generated by the VS.NET designer, to make sure there is no code similar
to TabPageCollection.Add(new TabPage()).
Regard,
Thi -
http://thith.blogspot.com