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 / July 2006

Tip: Looking for answers? Try searching our database.

Sharing a component across multiple tabs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
giles.thomas@gmail.com - 09 Jun 2006 18:02 GMT
Hi,

I have an application where multiple TabPages (within the same
TabControl) need to contain the same components; switching tabs changes
the data source feeding into the components.  I guess this is a problem
a lot of people have solved in the past, but I can't seem to get it to
work elegantly.

In my current implementation, each time I receive a "Selected" event
from the TabControl I switch over my data source, then add my data
panel to the newly-selected tab (which automatically removes it from
the previous tab).  This works reasonably well, but the data grid
"flickers" irritatingly - I suspect because of the reparenting.

I have tried making the TabControl and the data panel children of the
same parent Panel, laid out so that the tabs abut the data panel, and
simply changing the data source when the tabs change.  This avoids the
flickering problem - but unfortunately the 3D border of the TabPanel is
very visible, so it's obvious that the data panel is not on the
TabControl. If I could switch off the 3D border, this could look OK,
but I can't find any way to do that.

My final attempt was again to put the TabControl and the data panel on
the same parent Panel, but this time making sure that the data panel
was on top of the TabControl in the Z-order, and then listening for
Resize events from the TabControl and handling them by resizing the
data panel so that it precisely obscures the TabPanel.  This *almost*
works, but (a) the resizing happens a bit too slowly, and is very
visible to the user, and (b) it feels really really hacky :-)

There *must* be a better way of doing this, can anyone help me out?

Cheers,

Giles
GhostInAK - 09 Jun 2006 19:49 GMT
Hello giles,

You seem really stuck on the TabControl.  Any particular reason?  If the
actual display elements are not changing.. but rather just the data in the
elements, then a TabControl may not be your best option.  You might instead
consider toolbar buttons which would corrospond to your current tabs.. each
button could then stay depressed while that source was active.. You might
also consider a menu control similar to Outlook's (the one where you can
drop down your folder list when its hidden).  A simple listbox or listview
would serve well also (add a little custom drawing to make em pretty).

If you are bound and determined to use a tab control in this manner (which
will always be hacky) you may want to stick with your current attempt (reparenting)
and look at the Win32 API function LockWindowUpdate().

-Boo

> Hi,
>
[quoted text clipped - 31 lines]
>
> Giles
giles.thomas@gmail.com - 13 Jun 2006 12:59 GMT
Hi there, thanks for the reply!

Sadly, I have to use the TabControl - our users expect it as a result
of the UI choices in older applications.

I tried using the LockWindowUpdate call as you suggest, and it
certainly did reduce the flicker - indeed, I think it might have
eliminated that amount of it that was due to reparenting the data
panel.  However, there was still enough to be annoying.

I'm beginning to suspect I'm going to have to override the TabControl's
drawing functionality, so that I can just put a TabControl next to the
data panel, but make it look as if it is the parent.  Are there any
good resources out there that I could use to learn how to override .NET
component's redraw methods?

Regards,

Giles

> Hello giles,
>
[quoted text clipped - 48 lines]
> >
> > Giles
GhostInAK - 15 Jun 2006 20:39 GMT
Hello giles,

how about making a tab control that is only as tall (.Height) as the tabs
themselves.. then place your input control below it.. You might have to fixup
the borders a little bit.. but you wouldnt have any flickering.

-Boo

> Hi there, thanks for the reply!
>
[quoted text clipped - 71 lines]
>>>
>>> Giles
giles.thomas@gmail.com - 11 Jul 2006 18:02 GMT
Hi there, sorry for being so slow to reply... I did try the tab control
just as you suggested; fixing up the borders did prove problematic,
though, so I passed the problem on to one of my colleagues, a .NET guru
who had the idea of using the SetStyle method on the TabPage.  He set
the style to True for the flags AllPaintingInWmPaint, DoubleBuffer, and
UserPaint, and this fixed the problem perfectly.

Regards,

Giles

> Hello giles,
>
[quoted text clipped - 79 lines]
> >>>
> >>> Giles

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.