G
giles.thomas
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
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