By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,871 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,871 IT Pros & Developers. It's quick & easy.

prevent TabControl.ControlCollection to change SelectedIndex at Re

P: n/a
Hello everybody!

Please note that I have posted same question in different forums with no
success. So If you tried to help me there, please do not consider the repost
as rude!

I'm working on an application which has UserControls (GUI pages) with
TabControls on it.
This TabControls are Usercontrols derived from Windows.Forms.TabControl.
Same to TabPage.
The TabPage class has a "Visible" property which removes the TabPage from
TabControl.TapPages property, if it's set to false.
This Visible property is refreshed over an userdefined binding mechanism.
This means if I change my page, the Visible property of the TabPages will be
On default the SelectedIndex property of the TabControl is set to "0".

Now what's my problem:
I allways had strange visual effects as the TabPages where removed from the
I saw the different TabPages flickering until all the TabPages where removed.

Thank's to Lutz Roeder's reflector I found out that the framework is forcing
the SelectedIndex property after removing the tabpage.
public override void Remove(Control value)
if (value is TabPage)
int index = this.owner.FindTabPage((TabPage) value);
if (index != -1)
this.owner.SelectedIndex = Math.Max(index - 1, 0);

I now whant to find a solution which prevents the SelectedIndex property to
change when removing a TabPage.

What I was thinking of:
As the SelectedIndex property is not virtual I'm not able to override it in
my TabControl class.
Maybe I could inherit a TabPageCollection class, for my TabPages property of
TabControl class, which overrides the "Remove" or "RemoveTabPage" method. And
after that ????. Cause I have no access to importand fields which are
declared as internal!

Thanks for your time.

All the best,


Jun 28 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.