I have created a UserControl which is subsequently hosted on a standard
My control has a TabControl on it but it has no TabPages configured.
At runtime I create X pages and put a single RichTextBox on each page.
In my controls loaded event I call my Render() method which configures
everything appropriately. When setting up the TabControl the first thing
it says is (not real var names):
for (int i = 0; i < someInt; i++)
... add page to tab control
... add richtextbox to page
On my control there is a button which pops up a configuration dialog
whereby various settings that affect the usercontrol can be set.
Due to this I have to reinitialise by usercontrol when the dialog closes.
So thus when returning from it I call my Render() method.
When it gets to the line:
I get an "object reference not set to an instance of an object"
exception occur. I tried changing the line to:
if (myTabCtrl.TabPages.Count != 0) myTabCtrl.TabPages.RemoveAt(0);
...which will work in my test data's case; this again causes an object
not set error.
Anybody have any ideas why I can call the Clear() method when there
are no pages, but when I call it when there are I get the above error?