Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2005

Tip: Looking for answers? Try searching our database.

Minor bug in TabControl.TabPages.Remove().

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 25 Feb 2005 15:05 GMT
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);
}
Bruce Wood - 25 Feb 2005 18:10 GMT
Certainly a bug, but then I think that the whole TabControl / TabPage
thing is a bloody mess to start with. There are myriad problems with
the implementation, and I would be very happy if MS could see their way
clear to fixing them (or creating a whole new pair of classes that are
more usable than these). Some of my beefs include:

"No way" (without resorting to baroque solutions like overriding Paint
methods) to change the font / background colour / etc. etc. of the tabs
themselves--which is what you almost always want to do--but lots of
support for changing the font / background colour / etc. etc. of the
entire page, minus the tab (?)--which is almost never what you want to
do.

Support for ErrorProviders, but no way to show the user that an
ErrorProvider icon is flashing on some control on another tab page.
Flagging an error on a TabPage via an ErrorProvider does absolutely
squat.

No support for hiding, disabling or otherwise showing that a TabPage is
irrelevant in context, other than removing the TabPage from the
control, which is ugly.

No support for putting a TabPage back at an arbitrary point in the page
sequence, so if you make it "disappear" by removing it, you can't put
it back where it was without a lot of messing around, all of which
causes gross flickering and... well, yuck.

Various problems in their interactions with DataBindings: DataBindings
(apparently) don't populate controls that aren't currently visible, so
controls on tab pages other than the one currently selected don't get
populated by DataBindings until the user selects the tab page that
they're on, which can cause all sorts of problems. Well... data
bindings are a mess, too, so it's hard to say whose fault this one is.
:)

Anyway, as I said, I wish that MS would give us new TabPage and
TabControl classes that provide more reasonable functionality than
these ones do. Even if these ones still had no (technical) bugs they
would still be ugly hacks.
Matt Garven - 28 Feb 2005 01:04 GMT
Hi Bruce,

All good points!

You should enter them into the Product Feedback page to make sure someone at
Microsoft gives them a read:

http://lab.msdn.microsoft.com/productfeedback/Default.aspx

Regards,
Matt Garven

> Certainly a bug, but then I think that the whole TabControl / TabPage
> thing is a bloody mess to start with. There are myriad problems with
[quoted text clipped - 35 lines]
> these ones do. Even if these ones still had no (technical) bugs they
> would still be ugly hacks.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.