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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Nov 5, 1998

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Add Columns to a Standard VB List Box

Use the Win32 API to set tab stops in a Visual Basic list box by creating these declarations and routine in a module:

 Public Const LB_SETTABSTOPS = &H192
Declare Function SendMessage Lib "user32" _
	Alias "SendMessageA" (ByVal hwnd As Long, _
	ByVal wMsg As Long, ByVal wParam As Long, _
	lParam As Any)As Long
Sub SetListTabStops(iListHandle As Long)
' sets 2 tab stops in a list box at the 24th 
' and 48th character
' iListHandle = the window handle of the list box
Dim iNumColumns As Long
Dim iListTabs(1) As Long
Dim Ret As Long
	iNumColumns = 2

	iListTabs(0) = 96  ' 96/4 = 24 characters
	iListTabs(1) = 192 ' 192/4 = 48 characters
	Ret = SendMessage(iListHandle, _
		LB_SETTABSTOPS, iNumColumns, iListTabs(0))
End Sub

In your form, create a list box called lstMyListBox. Call this routine in the form load to set your tab stops:

 Call SetListTabStops(lstMyListBox.hwnd)

Then add items to the list box using vbTab:

 lstMyListBox.AddItem "Column 1 data" & _
	vbTab & "Column 2 data"
Catherine Spence
 
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