IgnaceMaes / MaterialSkin

Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles.
MIT License
2.86k stars 831 forks source link

Exception adding a tab to the MaterialTabControl when linked to the MaterialTabSelector #43

Closed lukeskinner closed 9 years ago

lukeskinner commented 9 years ago

When you have a standalone MaterialTabControl you can add tabs without issues in the form designer.

However when an instance of the MaterialTabSelector has the BaseTabControl configured it will throw exceptions in the OnPaint method inside the MaterialTabSelector.cs. This is because when the tab is added (or deleted) it does not recalculate the amount of rectangles to use causing exceptions here:

            g.DrawString(
                tabPage.Text.ToUpper(), 
                SkinManager.ROBOTO_MEDIUM_10, 
                textBrush, 
                tabRects[currentTabIndex], //This tabRects object has not been updated to reflect the new amount of tabs

Screenshot