Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

A Replacement For Tabs

You say you want to use a tab control, but you have so many topics the tabs will be unreadable? Try using a list box in conjunction with a control array of picture controls. The list box will contain entries the user can choose; the picture controls will be containers for the various form subsections desired. To demonstrate this, create a form with a list box (List1) on the left and a Picture box (Picture1) on the right. Set the Index property of Picture1 to zero, making it a control array. Then place this code in Form_Load:
 
Private Sub Form_Load()
	Dim x As Integer
	For x = 0 To 15
		List1.AddItem "Picture1(" & x & ")"
	If x > 0 Then Load Picture1(x)
	Picture(x).AutoRedraw = True
		Picture(x).AutoRedraw = True
		Picture(x).Visible = True
		Picture(x).Left = Picture1(0).Left
		Picture(x).Top = Picture1(0).Top
		Picture(x).Width = Picture1(0).Width
		Picture(x).Height = Picture1(0).Height
		Picture1(x).Print "This is picture " & x
	Next x
	Me.Show: Me.Refresh
	List1.ListIndex = 0

End Sub
In VB 4.0, you could use this syntax:

With Picture1(x)
	.AutoRedraw = True
	.Visible = True
	.Left = Picture1(0).Left
	.Top = Picture1(0).Top
	.Width = Picture1(0).Width
	.Height = Picture1(0).Height
End With
Note that for a real application you wouldn't dynamically create picture controls. You'd create them at design time and fill them with the controls you need. To demonstrate the concept, the example loads the control array at Form_Load. Place the following code in List1_Click:
 Picture1(List1.ListIndex).ZOrder
Whenever the user clicks an item in the list, the relevant picture control will pop to the top of the stack, becoming visible. This provides tab-like functionality without the cost of a VBX or extra memory, and lets you create items with as many pictures as you want, unfettered by tab width or tab caption readability!
Barry Seymour
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date