How to show two columns in a Listbox?

torg

Regular
Joined
Nov 7, 2002
Messages
60
Location
Norway
The topic probably describes my problem, but as a matter of form:
How do I show two columns in a Listbox.
i.e

I use: txtboxName, textboxBirth, textboxCity as input

I want some thing like this:
Visual Basic:
Name:       Birth                        City

John         12/12/1973             Paris
Carl          05/11/2004             Hamburg
Paul          01/02/1980            New York
Per            02/02/1975           Oslo

a code example would have been appreciated.
 
Last edited:
That sounds like a good Idea, I`ll try that. meanwhile, I`ve come up with some code that I could have used instead:

Visual Basic:
Public Class......
.
.
.
Dim bill(2) As Budget

    Structure Budsjett
        Dim mystring1 As String
        Dim mystring2 As String
        Dim mystring3 As String
    End Structure
,
,
,
Public Sub .......

 Bill(0).mystring1 = "Mystring"
 Bill(1).mystring2 = "Another String"
 Bill((2).mystring3 = "Yet another String"

Dim formatstring As String = "{0,-15}{1,0}{2,15}"

        Listbox1.Items.Clear()

        Listbox1.Items.Add(String.Format(formatstring, Bill(0).mystring1 , Bill(1).mystring2 , Bill(2).mystring3))

the drawback is that I want to populate the listbox with several columns from one mdb table. Any idea about how to do that?

This only gives me the data from column Expences
Visual Basic:
 ListBox1.DataSource = dsTenLast.Tables("dtTenLast")
 ListBox1.DisplayMember = "expencetype"
 
You could also look into using a DataGrid control; you can easily
load in a DataSet and display the info, and it would probably do
what you're asking about. I would suggest reading up on it.
 
I`ve already tried that, and It works fine. But somehow, don`t ask why, I`ve decided to use Listbox., or atleast try to. Provided that it satisfies my needs
 
Back
Top