• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1289
  • Last Modified:

TabControl bug found. Can I workaround it?

I'm using VS 2005.

I made a form that is split horizontally, with a TabControl in the upper panel. The TabControl should be resizable, but when I drag the split border downwards, the TabControl isn't redrawn like it should be. It appears to be a bug specifically in the TabControl.

Here's how to make it happen:

1. Make a new form.
2. Add a SplitContainer and make it horizontal.
3. Add a TabControl to the upper panel.
4. Anchor the TabControl in all four directions.
5. Start.

Drag the SplitContainer border down a bit, release, and see how the TabControl is not redrawn properly. Dragging the border upwards works as indended.

Now I wonder how to work around this. Using Update() on the TabControl (or the whole form) on the SplitterMoved() event didn't work. Installing the VS 2005 SP1 BETA didn't work either.

Note that the TabControl redraws perfectly when I resize the whole form, and when I drag the split border upwards. Perhaps these things are clues on how to make it work.

Also, where should I send bug reports on VS 2005?
0
liljegren
Asked:
liljegren
  • 3
1 Solution
 
Fernando SotoCommented:
Hi liljegren;

I have followed the steps you directed above but is seems to work on my system. I drag the SplitContainer border down a bit, release, and the tab control adjusted its size. Did you try this before loading VS 2005 SP1 BETA?

Fernando
0
 
whatsit2002Commented:
I have been able to duplicate your issue by following your directions except for step #4 in which I docked the tab control as "Fill" instead of anchoring it.

My solution, though not pretty, is to handle the resize event of the TabControl and all of its child TabPage controls. The following code worked for me:

        //tab control resized
        private void tabControl1_Resize(object sender, EventArgs e)
        {
            RefreshTabs();
        }
        //first tab page resized
        private void tabPage1_Resize(object sender, EventArgs e)
        {
            RefreshTabs();
        }
        //second tab page resized
        private void tabPage2_Resize(object sender, EventArgs e)
        {
            RefreshTabs();
        }

        private void RefreshTabs()
        {
            tabControl1.Refresh();
            tabControl1.SelectedTab.Refresh();
        }

This seems to mimic the functionality you would assume the control would have built-in.

The tab control is one of the more buggy .NET controls. It has been for a while. There are problems rendering the text on the tabs when you use them vertically instead of horizontally and the problem you found seems to be yet another bug in a long list.

Anyway, I don't think you're looking at a bug in VS 2005 so much as it is a problem with the .NET control from the framework itself. Good luck.

Thanks.

Jason
0
 
Fernando SotoCommented:
Hi Jason;

I was not able to duplicate the problem stated in the question, following the 5 steps. I also tried it your way with Dock set to Fill and was unable to duplicate.

Are you using SP1 BETA for VS 2005?

Fernando
0
 
Fernando SotoCommented:
Setting the TabControl's Dock Property to Fill is fine if you want to fill the whole panel with the TabControl. But if there are other controls on the panel then the other controls could end up behind the TabControl where they will not appear at run time or placed in front of the TabControl where they will show up on every TabPage.
0
 
liljegrenAuthor Commented:
Yes, I tried this before installing the beta. In fact, I installed the beta to see whether it would fix this, but there was no change. Here's a screen shot of what I get:

http://www.algonet.se/~gustafl/temp/wfbug.png

I also double-checked the instructions I gave to duplicate the bug, and this is really the result I get! The same happens also when I use Fill.

But the problem is solved. Jason's solution worked for me. It's just strange you couldn't duplicate it without setting the control to Fill. A good answer.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now