IgnaceMaes / MaterialSkin

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

Tab Selector Dies on Removing Tab Pages Dynamically #218

Open sahilkajani opened 6 years ago

sahilkajani commented 6 years ago

This is really a weird issue. So if there are 4 tabs in the tab selector, if I try to remove the last tab dynamically, it works fine. But if I try to remove any tab excluding the last tab, the tab selector dies.

tabs

I'm using the below code to remove the 4th tab and it work's fine

foreach(TabPage tabpage in materialTabControl1.TabPages)
          {
                 if(tabpage.Name == "tabPage4")
                {
                    materialTabControl1.TabPages.Remove(tabpage);
                    materialTabSelector1.Refresh();
                }
           }

mattab

But if I try to remove the 3rd tab with the below code. I get an error.

  foreach(TabPage tabpage in materialTabControl1.TabPages)
            {
                if(tabpage.Name == "tabPage3")
                {
                    materialTabControl1.TabPages.Remove(tabpage);
                    materialTabSelector1.Refresh();

                }
            }

mattaberror

ghost commented 5 years ago

I have the same problem... When i'm closing tabpage using project from github. It works without any error. If will use nuget package then i have the same issue? Any fix?