我試圖用一個ListView從數據集中顯示的記錄。在這些記錄中,我有4列:EmployeeID,EmployeeName,CustomerID和CustomerName。員工和客戶都可以多次列出,但可以使用不同的組合。VB.Net的ListView
例如,如果我們有員工1,2,3和顧客A,B,C,我們可以得到: (1A) (1B) (1C) (2A) (2B) 等
什麼事與我是我想補充說(1A)到ListView,然後當它試圖增加(1B)我得到一個錯誤說,它不能添加相同的項目。
這裏是我到目前爲止的代碼:
With list
.Clear()
.Columns.Add("Employee ID")
.Columns.Add("Employee Name")
.Columns.Add("Customer ID")
.Columns.Add("Customer Name")
For Each row As UpFromCostExceptions.dtExceptionsRow In _dsExceptions.dtExceptions
Dim lvItem As ListViewItem = .Items.Add(row.EmpID.ToString)
lvItem.SubItems.Add(row.EmployeeName)
lvItem.SubItems.Add(row.CustomerID)
lvItem.SubItems.Add(row.CustomerName)
Next
.Refresh()
End With
任何人都看到發生了什麼事?先謝謝您的幫助!
我不知道你在哪裏使用從合併字段中的數據。如果CustomerID是數字,則需要像使用EmpID一樣包含.ToString()。 – 2012-02-21 16:53:11
我沒有在單個字段中使用組合數據。但我有兩個listView的項目。這兩個項目對於EmpID具有相同的值,但對於CustomerID具有不同的值。當我嘗試添加第二項時,它會收到錯誤,因爲它無法添加相同的EmpID。 – 2012-02-23 16:06:35