Hi all,

I have a requirement as follows,

I have to display a list of datas in to a list box in button click functionality. When i click the button, values should be fetched from database table and loaded in to the list box.
for example: the database table has two values say,
item number
apple 10
pineapple 20
orange 10
jackfruit 25

i am succesfull in fetching the data and displaying it in the list in following way,
apple 10
pineapple 20
orange 10
jackfruit 25

Now i need to align it in the following way in to the listbox

apple              10 
pineapple          20
orange             10
jackfruit          25

how can i do this ?

Thanks in Advance
VBCoder123456

>> i am succesfull in fetching the data and displaying it in the list in following way,
- post your code

inside the button click i have written the following code

cmd = New SqlCommand("select * from  table", conn)
                billdatard = cmd.ExecuteReader()
                billListBox.Refresh()
                billListBox.Items.Clear()
                While billdatard.Read()
                    firstval = billdatard(0)
                    secondval = billdatard(1)
                    totval = firstval + 				System.Convert.ToString(secondval)
                    billListBox.Items.Add(totval)
		end while

i am able to concatenate the values, but i am not able to align it as mentioned above...

Hi, You can try String.Format()

Try this

Dim str As String
        'Here 20 is the width of the first string
        '-means Left Align, 0 and 1 are index
        str = String.Format("{0,-20} {1,2}", "Hi", 10)
        MessageBox.Show(str)

sir,
This code where i will put please show me

at the insert query or any other code


Thank you

hi realback..
Please do not resurrect old thread..just make your own thread.

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.