1

我有一个带有列表框的应用程序。单击按钮时,应该显示我的数据库中的某些内容。与显示一起出现列标题!!!它以“{itemID = SW934, quantity = 10...”等形式出现。如何摆脱“{”和列标题???这是我当前的代码:

公开课形式1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'MICROLANDDataSet.Orders' table. You can move, or remove it, as needed.
    Me.OrdersTableAdapter.Fill(Me.MICROLANDDataSet.Orders)
    'TODO: This line of code loads data into the 'MICROLANDDataSet.Inventory' table. You can move, or remove it, as needed.
    Me.InventoryTableAdapter.Fill(Me.MICROLANDDataSet.Inventory)
    'TODO: This line of code loads data into the 'MICROLANDDataSet.Customers' table. You can move, or remove it, as needed.
    Me.CustomersTableAdapter.Fill(Me.MICROLANDDataSet.Customers)

End Sub

Private Sub btnOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOut.Click
    Dim query1 = From OUT In MICROLANDDataSet.Inventory
                 Where OUT.quantity <= 10
                 Order By OUT.description Descending
                 Select OUT.itemID, OUT.quantity, OUT.description

    lstOutput.DataSource = query1.ToList
    lstOutput.SelectedItem = Nothing


End Sub

结束类

多谢你们。非常欢迎任何帮助。

4

1 回答 1

1

问题是这query1是一个匿名的内存队列。换句话说,它是未定义类型的对象的枚举。解决此问题的一种方法是将结果连接到一个字符串中。

 Select OUT.itemID & OUT.quantity & OUT.description

并使 query1 a List(Of String)(您可以按照自己的方式格式化字符串。)

另一种选择是将其中一个字段指定为显示字段。

lstOutput.DisplayMember="Description"
于 2012-08-04T00:04:08.283 回答