Hide

SftTabs/OCX 6.5 - Tab Control for VB6

Display
Print

Sharing Controls Between Pages

SftTabs/OCX allows easy sharing of controls. A shared control is a control that appears on more than one tab page. It is the same control, same name, same event code, etc. By default, new controls that are added inside a tab control are always added to the current tab page and only appear on this page. If you switch to another page, the controls of that page are hidden and disabled.

When you switch to another tab page, SftTabs/OCX saves a list of all controls that were visible on the current page. For each active control, its Left, Top, Width and Height properties are saved. The Enabled property is also saved (if available) and set to False.

As the new tab page becomes active, its list of active controls (that was saved when this page was left) is restored. All controls that were visible are updated, their Left, Top, Width, Height and Enabled properties are restored.

SftTabs/OCX does not check that controls appear only on one tab page. Any control that is found visible when a page is left is added to the list of active controls. This means, that ANY control that is visible will be added to the list, even if it already has been added to the list of another tab page.

Shared controls must have the same size and position on each tab page. (You could of course override the sizes as a page becomes active in the Switched event). When using this method, keep in mind that the Left, Top, Width, Height and Enabled properties of each visible control are saved. They will be restored when the page becomes active again later.

How To Share A Control

Once a tab control has been added to a form, these are the steps to share a control between tab pages:

  • Make the tab active where you want the control to appear and add the control to it. Make a note of the Left and Top properties that the control has at this time.
  • Now switch to another tab where the same control should also appear. The control is not visible on the tab page.
  • Select the control in Visual Basic's Property Window. You'll notice that the control has Left and Top properties which are negative. Change these properties to the values as they appeared when the first tab was active. The control is now visible. Make sure to update the Enabled property also.
  • The same control can be shared with additional tab pages by repeating the same process for each tab page where you want the same control appear. Any other tab pages where you don't change the control's Left/Top properties will not display the control.

How To Stop Sharing A Control

Important: Do not delete the control. Deleting the control will remove it from all tab pages.

If you are sharing a control between tab pages and you want to remove it from certain pages, follow these simple steps:

  • Select the tab page where you no longer want the control.
  • Select the control. Now change the Left and Top properties to -10000 and -10000 (or any other large negative value) and set the Enabled property to False.
  • Click on another tab (this saves the changes).
  • The control is no longer visible on the page.

Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.