我需要一個簡單的方法來從當前項目的數據庫填補值被添加,這樣我可以在以後使用它:填充值到列表框控件在Vb.Net
'Filling the MAIN Categories part
Dim DataAdapterCatm As New MySqlDataAdapter("SELECT id,title From catM;", MySqlConnection)
Dim dsMc As New DataTable
DataAdapterCatm.Fill(dsMc)
For counter = 0 To dsMc.Rows.Count - 1
LbMCat.Items.Add(dsMc.Rows(counter).Item("title").ToString)
'LbMCat.ValueMember = dsMc.Rows(counter).Item("id").ToString
'The above line don't work, I need something to replace it
Next
而我該如何捕獲selectedvalue,因爲它現在拋出DataView錯誤爲String錯誤 –
'SeletedValue'應該是上面代碼中的字符串。嘗試將'ValueMember'和'DisplayMember'賦值放在'DataSource'賦值的上方。 – shf301
再次錯誤,這是錯誤:對象引用未設置爲對象的實例。 –