Try
strQuery = "SELECT * FROM thesis_db.std_records WHERE ProfIDNo=" & lstProfID.SelectedItem & " AND SubjectNo=" & SubjNo & " order by Student_LName"
MysqlCmd = New MySqlCommand(strQuery, MysqlConn)
MysqlDR = MysqlCmd.ExecuteReader
Dim arr(3) As String
Dim itm As ListViewItem
While MysqlDR.Read
arr(0) = MysqlDR.Item("Student_LName").ToString
arr(1) = MysqlDR.Item("Student_FName").ToString
arr(2) = MysqlDR.Item("Student_MI").ToString
arr(3) = MysqlDR.Item("Score").ToString
itm = New ListViewItem(arr)
lstStudent.Items.Add(itm)
End While
MysqlDR.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
错误在以下行:lstStudent.Items.Add(itm)。它带有下划线,并且错误提示:'Public Sub New()'的参数过多。
最佳答案
尝试这样的事情:
变化:
itm = New ListViewItem(arr)
lstStudent.Items.Add(itm)
有了这个 :
For i=0 to 3
Dim lvi As New ListViewItem(arr.ToString())
Me.lstStudent.Items.Add(lvi)
Next
'if you want subItem
lvi.SubItems.Add(array2(i))
关于mysql - WPF vb.net使用Mysql数据库填充Listview,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28713812/