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 August 22nd, 2005, 01:00 AM
Authorized User
 
Join Date: Jul 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default list10.column(0).additem? hah!

Private Sub Command2_Click()
Rem fetch
Me.List10.RowSource = ""
rst.Open "select * from Qns_Table", cn
rst.MoveFirst
Do While Not rst.EOF
    Me.List10.AddItem rst!QnsID
    'Me.List10.AddItem rst!Question
    rst.MoveNext
Loop
rst.Close
End Sub



is there anyway that i can have my QnsID and Question displayed in seperate column of the List10 (list box)?

i've tried something out of the world and here goes...
Me.List10.Column(0).AddItem rst!QnsID
Me.List10.Column(1).AddItem rst!Question

of course, it isn't suppose to work =P

can someone advice me on this?

Thanks

Astro

 
Old August 22nd, 2005, 12:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

set the Columns property of the list box to something different than 1, and use vbTab to separate the columns when you add an item, like

list1.add "first" & vbtab & "second"

if you neeed more control on the layout, I suggest you switching from the ListBox to the ListView in report mode.

Marco
 
Old March 6th, 2007, 03:51 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peace_msngr
Default

You Can Use your code such as following:

Me.List10.ColumnCount = 2
Me.List10.RowSourceType = "Value list"
Me.List10.ColumnWidths = "Xcm;Ycm" ' X & Y :any size



Private Sub Command2_Click()
Rem fetch
Me.List10.RowSource = ""
rst.Open "select * from Qns_Table", cn
rst.MoveFirst
Do While Not rst.EOF
    Me.List10.AddItem rst!QnsID & ";" & rst!Question
    rst.MoveNext
Loop
rst.Close
End Sub

This Method Creates 2 column separately. ;)






Similar Threads
Thread Thread Starter Forum Replies Last Post
List box AddItem bogs down williamlove Access VBA 4 November 8th, 2008 11:46 PM
ListBox.AddItem In Access 2000 tready Access VBA 3 August 17th, 2006 01:11 PM
previous column & next column ct Excel VBA 4 August 19th, 2005 04:50 AM
template column and bound column hidayah ASP.NET 1.x and 2.0 Application Design 1 April 9th, 2005 03:50 PM
Compare two Items of data(in column A and column B ever Excel VBA 6 February 13th, 2004 02:19 PM





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