[VB.NET]vb.net中 listbox 问题

前端之家收集整理的这篇文章主要介绍了[VB.NET]vb.net中 listbox 问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
vb.net中 listBox 问题 vb.net中 listBox控件 数据通过数据库绑定 显示多条记录 设为多选后 在界面上选择两条以上记录时 后台怎样能够取得所选记录的值 为什么我取得总是system........之类的 __________________________________________________________________________ Me.ListBox1.SelectedItems(0).ToString() Me.ListBox1.SelectedItems(1).ToString() 这样就行了吧? __________________________________________________________________________ Dim i As Integer For i = 0 To ListBox1.SelectedItems.Count - 1 MessageBox.Show(Me.ListBox1.SelectedItems(i).ToString()) Next __________________________________________________________________________ listBox 绑定代码 ListBox1.DataSource = Db.OraDataView ListBox1.DisplayMember = “字段名” 取值 For i As Integer = 0 To ListBox1.SelectedItems.Count - 1 MessageBox.Show(Me.ListBox1.SelectedItems(i).ToString()) Next 显示为: System.Data.DataRowView 而不是我数据库里的值 这是怎么回事啊 __________________________________________________________________________ While Rd.Read() ListBox1.Items.Add(Rd.Item( "a ")) End While 绑定后再测试没有问题! __________________________________________________________________________ Rd 是什么啊 __________________________________________________________________________ Dim Conn As OleDbConnection Dim Cmd As OleDbCommand Dim Rd As OleDbDataReader Dim sql As String Dim Adpt As OleDbDataAdapter Dim Ds As DataSet Dim Provider = "Provider=Microsoft.Jet.OLEDB.4.0 " Dim Database = "Data Source= " & Application.StartupPath() & "/db1.mdb " Conn = New OleDbConnection(Provider & "; " & Database) Conn.Open() ''打开数据库 sql = "Select * From one " Cmd = New OleDbCommand(sql,Conn) Rd = Cmd.ExecuteReader() While Rd.Read() ListBox1.Items.Add(Rd.Item( "a ")) End While Rd.Close() Conn.Close() __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/263904.html

猜你在找的VB相关文章