ListViewBox Not Cooperating

Greetings:

I'm trying to iterate through a table in a DataSet and display the rows in a ListViewBox. The stored procedure used works fine in the database, and the debugger shows that my DataSet is filled with exactly the records I'm looking for. But the ListViewBox does not show the columns I set up for it, and only displays part of one field from each record, arranged in neat rows and columns. I know that this is real basic stuff, but I'm just not getting it.

Here's the code:

Private Sub btnTablesRead_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles btnTablesRead.Click

'check to see which table has been selected

If rdoTableMiles.Checked Then

Sproc = DBLink.MilesRecords

ElseIf rdoTableHours.Checked Then

Sproc = DBLink.HoursRecords

ElseIf rdoTableTasks.Checked Then

Sproc = DBLink.TasksRecords

End If

'clear listviewbox

lvwTableLoad.Items.Clear()

Dim lvi As ListViewItem

Select Case Sproc

Case DBLink.MilesRecords

'This sproc works in the Access DB.

Dim objLink As New DBLink(Sproc, "Trips")

'This call works, the dataset is filled with the records I'm after.

lvwTableLoad.Columns.Add("TripID", 100, HorizontalAlignment.Left)

lvwTableLoad.Columns.Add("TripDate", 100, HorizontalAlignment.Right)

lvwTableLoad.Columns.Add("TripDestination", 150, HorizontalAlignment.Left)

lvwTableLoad.Columns.Add("TripEnd", 100, HorizontalAlignment.Left)

lvwTableLoad.Columns.Add("TripMiles", 100, HorizontalAlignment.Right)

Dim dr As DataRow

For Each dr In objLink.objDataSet.Tables("Trips").Rows

lvi = lvwTableLoad.Items.Add(dr.Item(0).ToString)

lvi.SubItems.Add(dr.Item(1).ToString)

lvi.SubItems.Add(dr.Item(2).ToString)

lvi.SubItems.Add(dr.Item(3).ToString)

lvi.SubItems.Add(dr.Item(4).ToString)

lvi.SubItems.Add(dr.Item(5).ToString)

Next

Case DBLink.HoursRecords

Case DBLink.TasksRecords

End Select

End Sub

Thanks for your help!



Answer this question

ListViewBox Not Cooperating

  • windows_mss

    Do you have your listview "View" property set to details If not this could be part of the problem.


    Please post some of the code you need help with (it makes it easier to help you) :p
    When you have eliminated the impossible, whatever remains, however improbable, must be the truth.
    -Sir Arthur Conan Doyle-


  • LukaSoFt

    Greetings ProphetBeal:

    Bingo. That was the problem. I had a feeling that it was a dum-dum thing like this. Thanks for your help!


  • ListViewBox Not Cooperating