Experts, am I right about this? [TabControl insanity]

L

lisa

I just finished working on a control that made me completely nuts.
It's a tab control, and it works beautifully in an IE browser. Just
like the kind that are used in desktop apps (multiple rows of tabs that
rearrange themselves appropriately when clicked).

The control has a collection of tabs in it. I initially tried using
CollectionBase for the collection, because I figured it'd be less work.
Heh.

My major problem was that controls placed on one of the tabs manually
didn't retain their values and their events didn't get raised. And I
*knew* that was wrong, because the Microsoft MultiPage control doesn't
have that problem.

So I tried cannibalizing their control. But then I noticed that the
MultiPage control doesn't have a collection editor. And why should it?
The PageView controls have no design properties that you'd need to
edit.

So I went to look at their TabStrip, which does use a collection
editor. But those wacky folks at Microsoft... they used CollectionBase
for the TabStrip and ControlCollection for MultiPage. And you don't
place controls in a TabStrip, so they didn't have to worry about
persisting those.

Turned out that because my TabControl has a Controls property, and it
also has a Tabs property (which exposes a TabCollection), I needed to
be storing each Tab *twice*. If it wasn't stored in Tabs, the
collection editor couldn't see it. If it wasn't stored in Controls,
any controls placed on a Tab would have its ViewState and events
ignored.

Which then required a custom builder, because when I'd edit the damned
collection and then switch to HTML view, the base control builder would
show both collections (Tabs and Controls), and I'd get conflicting IDs.

I had to find a way to ensure that the contents of the TabCollection
and the Controls collection stayed in sync. It was kludgy and made me
want to go and shower, but by damn, it seems to work.

It works. And it doesn't require an .htc file to be installed
anywhere. And as far as I can tell so far (wait until I beat on it
some more), it does everything that I want it to do.

But the Tabs/Controls thing really irks me. I asked a million times if
anyone here knew why I was having that problem with the child controls,
and either no one knew the answer, or no one wanted to answer, and I
suspect it was the former.

So I'm going to post the full code for the TabControl on my website
tonight. It's free for the taking. And if anyone can figure out how
it might be possible to get it to work without all of the lameass
workarounds, I would be eternally grateful.

The address is going to be

http://www.starways.net/twisted/tabcontrol.zip

Wait until like 8pm CDT to try for it, but it should be up by then.

Lisa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top