Hello,

I would like to list items from a database into a list but like to make it look clean.

For example if database contains

Column1, Column2
John,Smith
Joe, Bloggs

I want to list them like this

John Smith
Joe Bloggs

Not like this (currently)

John Smith
Joe Bloggs

Any ideas to create the list, I can pull of the length but cannot change the string length to a desired length.

if Len(var) < 20 then
<how to make length = 20>
end if

The white space must of got deleted, hopefully you understand what I mean. I want the columns to be flush not overlapping because it looks messy.

With the list I am merging columns 1 and 2 together and then adding them as a list item

'Example Only
var1 = textbox1.text
var2 = textbox2.text

allVars = var1 & " " & var2

list1.items.add(allVars)

Look into String.PadRight()

Example:

Console.WriteLine("John".PadRight(20, " "c) & "Smith")
        Console.WriteLine("Joe".PadRight(20, " "c) & "Bloggs")
        Console.Read()

unless you are using a fixed width font such as Courier New then you are better to go with a multiple column approach. Like the one below using a list view

Dim rowvals(1) As String

        Me.ListView1.Columns.Add("Given", 50)
        Me.ListView1.Columns.Add("Surname", 70)
        ListView1.View = View.Details
        rowvals(0) = "John"
        rowvals(1) = "Smith"

        Dim newrow As New ListViewItem(rowvals)

        Me.ListView1.Items.Add(newrow)
        rowvals(0) = "Joe"
        rowvals(1) = "Bloggs"

        Dim row2 As New ListViewItem(rowvals)

        Me.ListView1.Items.Add(row2)

Hello,

Thank you both for your help, both are solutions to what i need and will come in very handy.

Thank you again

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.