0

Hi, I'm having trouble lining up data from a file with their respectable columns in a list box. I am using print zones to space out data evenly, but when i run the program the output is still messy. So I need help lining up columns properly together. As of now, the first 2 list box items line up with each other perfectly, the data i am looping through to add to list box is not lining up correctly. I have changed my zones several times, but still no luck. Any suggestions?

A chunk of my code (some) :

Dim fmtstr1 As String = "{0,-5} {1,20} {2,7} {3,7} {4,7} {5,7} {6,7} {7,8} {8,12}"
        Dim fmtstr2 As String = "{0,-5} {1,20} {2,7} {3,7} {4,7} {5,7} {6,7} {7,8} {8,12}"
        Dim fmtstr3 As String = "{0,-5} {1,10} {2,7} {3,7} {4,7} {5,7} {6,7} {7,8} {8,12}"

        lstReport.Items.Add(String.Format(fmtstr1, _
                                  "Name", _
                                  "ID", _
                                  "Mon", _
                                  "Tue", _
                                  "Wed", _
                                  "Thu", _
                                  "Fri", _
                                  "Total", _
                                  "Average"))

        lstReport.Items.Add(String.Format(fmtstr2, _
                          "----", _
                          "--", _
                          "---", _
                          "---", _
                          "---", _
                          "---", _
                          "---", _
                          "-----", _
                          "-------"))

            lstReport.Items.Add(String.Format(fmtstr3, _
                                Records(i).first & "   " & Records(i).last, _
                                Records(i).ID, _
                                Records(i).monSales, _
                                Records(i).tuesSales, _
                                Records(i).wedSales, _
                                Records(i).thurSales, _
                                Records(i).friSales, _
                                total, _
                                average))
2
Contributors
2
Replies
8
Views
7 Years
Discussion Span
Last Post by xcarbonx
0

Here is something to get started with using a ListView.

'// customize.
        ListView1.View = View.Details '// delete "Details" for other options from IntelliSense.
        ListView1.CheckBoxes = True '// add checkboxes.
        ListView1.FullRowSelect = True '// select entire row when SubItems are listed.
        ListView1.LabelEdit = True '// edit the item's value.
        ListView1.GridLines = True '// show grid lines.
        ListView1.AllowColumnReorder = True '// rearrange columns.
        ListView1.Sorting = SortOrder.Ascending '// alphabetize.
        '// add columns.
        ListView1.Columns.Add("Column 1", 150)
        ListView1.Columns.Add("Column 2", 150)
        ListView1.Columns(0).DisplayIndex = 1 '// rearrange columns.

        ListView1.Font = New Font("Verdana", 12) '// change font.
        ListView1.ForeColor = Color.WhiteSmoke  '// change forecolor.
        ListView1.BackColor = Color.SlateGray  '// change backcolor.

        '// add items.
        ListView1.Items.Add("item 1")
        ListView1.Items(0).SubItems.Add("subitem for 1")
        ListView1.Items.Add("item 2")
        ListView1.Items(1).SubItems.Add("subitem for 2")
        ListView1.Items(1).Font = New Font("Webdings", 16) '// change single item's font.
        ListView1.Items(1).ForeColor = Color.LightSteelBlue   '// change single item's forecolor.
        ListView1.Items(1).BackColor = Color.LightSeaGreen   '// change single item's backcolor.
        ListView1.Items.Add("item 3")
        ListView1.Items(2).SubItems.Add("subitem for 3")
0

Im not familiar with list view, is there anyway other than print zones to space columns correctly?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.