Combo box refresh problem VB .NET
-
Hi All, I think I confused the issue when I last posted this so I am trying again. I need to refresh a combobox list (in VB .net) when a new item as been added to the SQL database. I cannot find any example of how this is achieved and it is very different from VB6 which I am used to. I am still trying to get to grips with .net! I have a sub which calls a form so the user can add details of an item, and when it returns from the form (which inserts the item in the database) I need to update the list in the combo box, which is bound to a datasource on the form. I would be most grateful for any assistance David Loring
David Loring !! Keep Music Live !!
-
Hi All, I think I confused the issue when I last posted this so I am trying again. I need to refresh a combobox list (in VB .net) when a new item as been added to the SQL database. I cannot find any example of how this is achieved and it is very different from VB6 which I am used to. I am still trying to get to grips with .net! I have a sub which calls a form so the user can add details of an item, and when it returns from the form (which inserts the item in the database) I need to update the list in the combo box, which is bound to a datasource on the form. I would be most grateful for any assistance David Loring
David Loring !! Keep Music Live !!
It's done the exact same way to got the data into the ComboBox into the first place. Reload the data from the SQL source and rebind to the combobox.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
It's done the exact same way to got the data into the ComboBox into the first place. Reload the data from the SQL source and rebind to the combobox.
Dave Kreskowiak Microsoft MVP - Visual Basic
Hi Dave I thought I had done this...code below...but it does not seem to refresh Private Sub cmdAddDistrict_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddDistrict.Click 'Adds a new district to the list Dim frmRD As New RegDistrict_Add Using frmRD frmRD.ShowDialog() CountyForRegDistrictBindingSource.ResetBindings(False) cboRegDistricts.Refresh() End Using End Sub What am I doing wrong??
David Loring !! Keep Music Live !!
-
Hi Dave I thought I had done this...code below...but it does not seem to refresh Private Sub cmdAddDistrict_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddDistrict.Click 'Adds a new district to the list Dim frmRD As New RegDistrict_Add Using frmRD frmRD.ShowDialog() CountyForRegDistrictBindingSource.ResetBindings(False) cboRegDistricts.Refresh() End Using End Sub What am I doing wrong??
David Loring !! Keep Music Live !!
You called ResetBindings. You did NOT re-fetch the data from the database. Calling Refresh on the combobox just redraws the image of the combobox. It doesn't refresh the data in it.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
You called ResetBindings. You did NOT re-fetch the data from the database. Calling Refresh on the combobox just redraws the image of the combobox. It doesn't refresh the data in it.
Dave Kreskowiak Microsoft MVP - Visual Basic