h开发者_开发问答ow to refresh combobox items in vb .net
If you're talking about a comboBox on a WinForm that's been assigned to a list of objects using the datasource property, I found that you must nullify the datasource setting and re-assign it every time your list changes.
i.e.
attendanceDataFiles.DataSource = Nothing
attendanceDataFiles.DataSource = myFileList.files
attendanceDataFiles.DisplayMember = "displayName"
attendanceDataFiles.ValueMember = "fileName"
This is another way to refresh combo box items if your combo box's content is from MySql Database. You can customize your results in the query.
comboboxname.Items.clear() 'empty combo box content first
query = "select code, description from tbl_mode_of_payment where cat = 'LICENSE'" 'mysql query that retrieves payment code and its description based on category
cmd = New MySqlCommand(query, con)
reader = cmd.ExecuteReader()
While reader.Read
comboboxname.Items.Add(reader.GetString("code") + " - " + reader.GetString("description")) 'add results into the combo box
End While
con.Close()
Textbox1.Item.Clear() then call.item_tb()
精彩评论