Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2004, 01:28 PM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add multi column data to listbox

How do I add multiple column data to a list box in VB6?
Regards,
Brian
 
Old April 12th, 2004, 01:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this (I did not test it, just cut and paste from one of my projects.) This adds one tab stop in the list box.
As a suggestion, I prefer to use the ListView.
Marco

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
  (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_SETTABSTOPS = &H192


Dim i As Long
Dim ltab(0) As Long
ltab(0) = 30
SendMessage myListBox.hwnd, LB_SETTABSTOPS, 1, ltab(0)
myListBox.AddItem "fisrt column" & vbTab & "second column"
 
Old April 12th, 2004, 02:07 PM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How would I add multi-columns to a list view? Basically I want to list ID, Date, Text of various records on the screen then have the user be able to pick that record. The ID, Date, and Text will be used later for an INSERT statement.

Quote:
quote:Originally posted by marcostraf
 Try this (I did not test it, just cut and paste from one of my projects.) This adds one tab stop in the list box.
As a suggestion, I prefer to use the ListView.
Marco

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_SETTABSTOPS = &H192


Dim i As Long
Dim ltab(0) As Long
ltab(0) = 30
SendMessage myListBox.hwnd, LB_SETTABSTOPS, 1, ltab(0)
myListBox.AddItem "fisrt column" & vbTab & "second column"
 
Old February 21st, 2008, 06:17 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did anyone ever answer BradLee's question? I'm having the same issue as well and would love to hear from you.

 
Old April 29th, 2008, 07:48 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,

As, marcostraf stated, it tells and shows how a list box can hold the multi column data in single row with tab separated.

In fact, a list box is designed to have only one column and it works best for it. if you need multiple column control then, try using
- listview control (best choice)
- hierarchical flexgrid (only if you want it to work as excel sheet)
- or Adodb Datagrid (not recommended)

Give a try on these controls.

Hope this helps.

With Regards,
Raghavendra Mudugal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Colum Listbox JAdkins Classic ASP Basics 3 July 9th, 2007 01:40 AM
SOS!How to realize multi-column asp.net ListBox? xewei VS.NET 2002/2003 2 June 3rd, 2007 09:24 PM
multi column listbox or combolist in VS 2005 alexdcosta ASP.NET 2.0 Basics 2 June 23rd, 2006 11:20 AM
multi-colmumn listbox e4thenf4 Beginning VB 6 0 September 7th, 2004 01:31 PM
Adding data into multi-column listbox Ciarano VB How-To 5 March 31st, 2004 05:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.