I have the following code for adding information from and array to a listbox

    private void buttonAdd_Click(object sender, EventArgs e)
        {
          //add tracks to my tracks Add Tracks list box and tracks list box

            myTracksString[nextAvailbleRow, 0] = textBoxArtist.Text;
            myTracksString[nextAvailbleRow, 1] = textBoxSongName.Text;
            myTracksString[nextAvailbleRow, 2] = ((numericUpDownHours.Value * 3600) + (numericUpDownMinutes.Value * 60) + numericUpDownSeconds.Value).ToString();
            nextAvailbleRow++;

            textBoxSongName.Text = "";
            textBoxArtist.Text = "";
            numericUpDownHours.Value = 0;
            numericUpDownMinutes.Value = 0;
            numericUpDownSeconds.Value = 0;

            listBoxAddTrack.Items.Clear();

            for (int indexInteger = 0; indexInteger <= 199; indexInteger++)
            {
                listBoxAddTrack.Items.Add(myTracksString[indexInteger, 0] + "   " + myTracksString[indexInteger, 1] + "  " + myTracksString[indexInteger, 2]);

            }

The issue I have is when I add the information it doesn't line up in columns i.e. row 1 has 3 columns but then in row 2 the columns line up differently if the number of letters in that column is more than the number of letters in column 1, row 1.

So what I am wanting to know is how can I write some code that allows each column to line up in the same place regardless of how many letters are in each word. Hope that makes sense !!

Plz place CODE tags around your code to separate it from other text

Can you clear you problem can't understand.....

do you want to print like this


Sting Fields of gold 260
The Police So Lonely 270
U2 One 254

Use two listboxes instead of using one and use them as 2 columns another way is to use datagridview instead of listbox..... Can you please tell about the type of your data any what functions are you going to apply on the list box

what I am after is that in one column the artist will line up, then in the next column the name of the song will line up and finally in the last column the time in seconds of the song will line up.

In terms of the data it is just going to be displayed, but it has to be in just one list box

Is it must to be displayed in listbox or anyother control can be used for this purpose?

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.