Hello,
I have created a frame (frmRGC_Interface) with a pane which is the container for a user control. I have five different user controls, each of them with a UltraTab control "tabInterface" containing the same tabs.
The parent frame (frmRGC_Interface) which contains the pane is replacing the displayed user control within the pane, so I will dispose the last used user control before I display a new one. The idea is to keep the last activated (selected) tab. I tried to do the following:
-- in the user control's dispose event, I set a friend shared variable "frmRGC_Interface.curTab" to the key of current active tab like:frmRGC_Interface.curTab = tabInterface.ActiveTab.Key
-- in the new event of the user control, I set the tab like: tabInterface.Tabs(frmRGC_Interface.curTab).Active = True
Problem: each time the NEW event is processed, the system always reactivates the first tab of tabInterface.
How can I keep the activation of a tab (or transfer the actviation status between user controls) ?
ThanksStephan
The New method is not an event. It is a constructor which creates a new instance of your UserControl. That new instance has completely different values for its member variables (including curTab) than the previous instance of the UserControl. The value which was saved in the dispose event on the previous UserControl cannot be used in the constructor of the next UserControl. Instead, you must save this value on another class or make it a static variable instead of an instance variable.
Hello Mike,
maybe you have misunderstood what I do:
I create a parent control, then from there child user controls (placed in a panel within the parent control). The parent control has a variable curTab which is doing and working as you describe: it will get the key of the last used tab. This assignment to the curTab variable will be done in the dispose method of the user control , so I can "transfer" the value from one to another user control in saving the value in the parent control, from the parent control to the next instance of the user control (will be done in its new method (or I can use load event, has the same effect).
So this is not my problem how to get the key value into the parent related variable. The problem is the new method.Of course, I will use new methods or load events in order to initialize control settings. But the behaviour of the tab control is different compared to other controls concerning tab activation.
Therefore, let me ask you as follows: how can I preset the activation of a tab during initialization of the user control or frame which hosts the ultratab control (besides manipulating the code generated designer file) ?
you are right: to preset the tab, I have to use the "Selected" property, to determine the last active one (which is selected as well), I use the ActiveTab.key property.
ThanksStephan.
I apologize Stephan, I think I misunderstood your original description. Now that I look at it again, I do notice a problem with the code. It is caching the ActiveTab and setting Active on the corresponding tab in the new tab control. Try caching the SelectedTab and setting Selected on the corresponding tab in the new tab control. I believe 'active' is the tab item with focus. 'Selected' is the tab which is currently in view.