G
Guest
I’ve just found a minor bug in how the TabControl selects the SelectedTab
after you remove a TabPage.
The code from TabControl.ControlCollection.Remove is shown below (thanks
Reflector!) notice that the SelectedIndex is always set even if a different
TabPage was selected previously. For example, I have three TabPages with the
first one selected. I remove the last which sets the SelectedTab to the
second TabPage even though it should stay on the first.
public override void Remove(Control value)
{
base.Remove
(value);
if (!(value is TabPage))
{
return;
}
int num1 = this.owner.FindTabPage((TabPage) value);
if (num1 != -1)
{
this.owner.RemoveTabPage(num1);
this.owner.SelectedIndex = Math.Max((int) (num1 - 1), 0);
}
this.owner.UpdateTabSelection(false);
}
after you remove a TabPage.
The code from TabControl.ControlCollection.Remove is shown below (thanks
Reflector!) notice that the SelectedIndex is always set even if a different
TabPage was selected previously. For example, I have three TabPages with the
first one selected. I remove the last which sets the SelectedTab to the
second TabPage even though it should stay on the first.
public override void Remove(Control value)
{
base.Remove
(value);
if (!(value is TabPage))
{
return;
}
int num1 = this.owner.FindTabPage((TabPage) value);
if (num1 != -1)
{
this.owner.RemoveTabPage(num1);
this.owner.SelectedIndex = Math.Max((int) (num1 - 1), 0);
}
this.owner.UpdateTabSelection(false);
}