Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Command Buttons on multiple tabs 2

Status
Not open for further replies.

michelleDub

Technical User
Jun 3, 2003
16
IE
Hi
I'm trying to get VB command button to appear on ever tab of an already created VB application. There are 10 tabs and I want the same code to be used for the button on each tab with same button appearin gon each.
Any advice would be really appreciated.
Thanks in advance
 
Each command button must be unique, but you can use the same code but using an array of buttons. Look at help if you need help with arrays.
 
I don't know what tab control you are using. There are lots of them, and each one behaves differently. But this should work with most of them.

Make a control array of command buttons. Easiest way to do that is to copy and paste the same command button (the first time, you will be asked if you want to make a control array; say yes) to each of the tabs. All the command buttons with have the same name, but a different index property. They will also share the same event code, with an additional index argument passed if you need to figure out which member of the array fired the event. You don't, so just ignore the index argument.

Bob
 

There is a much easier way to have a single command button on all tabs if you are using either the SSTab or the TabStrip controls.

Add a command button to the form and right click on it. Select Bring To Front (This adjust the zorder of the command button.) and position the command button as if its container was the tab strip and not the form.

Run and click through the tabs to test.

Good Luck

 


Hi Michelle:

If the command button is to appear in the same place on all tabs of a SSTab control, there is a simple technique. Place the command button in the form, not in the tab control. Then use the menu function "Format | Order | Bring To Front (Ctrl + J)". Then drag the command button to the desired position on the tab control. With the command button contained by the form and not by the tab control, the button will always appear, regardless of which tab is selected. One button, one block of code.

Cassie
:)


 

Hi vbprrgmr:

You and I are on the same wavelength. It's just that you were a little faster in posting.

Cassie
:)
 
This may thow things off when the form is resized and so you will also need to re-position the command button.

Why not place the SSTab on a frame a little larger than the SSTab. Then the command button doesn't need to be re-positioned.
You could also make the frame just a little longer than the SSTab and place the button, and additional buttons right along the bottom of the SSTab.
 
There is one other method:

Place a small Frame (I'll call it Frame1) on the SSTab Tab1, a little larger than the Command button.
Place a Command button (Command1) on the Frame.
Set the Frame1.Top position to the desired position (here I used 360 - if you have 2 or more rows of tabs, you will need to take this also into consideration).
Set the Frame1.BorderStyle to 0 - None
In the SSTab1_Click event, set the Left position of Frame1 to the desired number, such as 0:


Private Sub SSTab1_Click(PreviousTab As Integer)
Frame1.Left = 120
End Sub

The single command button
should now show up on every tab.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top