views:

178

answers:

1

HI,

This question has been asked a lot on the web but all of them seems to be confused with windows forms and asp.net forms so I had to finally come here for answer.

I have a Main form (a window form) in VB.NET which has a Combo Box to display a list of countries. A sub form activated from a "Button" on the Main form allows users to add Countries to their list. But After Adding a new entry the Combo Box on the Main form does not show the update (while it is still open). I have to exit the main form and relaunch it to see the update.

The populate function in shown below. I call this method after adding new countries but still; not good. I have used Invalidate function of combo box but of no use as well.

Any Help is appreciated. Thanks

Public Sub PopulateCountry()
Dim rsLocal As New ADODB.Recordset
    Try

      Dim sSQLCommand As String
      Me.CountryList.Items.Clear()
      'get the list of countries from the local database
      sSQLCommand = " SELECT *  FROM CountryList order by CountryDesc"
      rsLocal.Open(sSQLCommand, cnn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
      'Display All the  countries
      While rsLocal.EOF = False

        Dim Country As New modGV.cbItem
        Country .ID = rsLocal.Fields("CountryID").Value
        Country.name = rsLocal.Fields("Country Desc").Value.ToString.Trim
        Me.CountryList.Items.Add(Country)
        rsLocal.MoveNext()
      End While

      rsLocal.Close()


    Catch ex As Exception    

      Debug.WriteLine("PopulateCountry: exception occurred " & ex.Description)

    Finally
      If rsLocal.State = ConnectionState.Open Then
        rsLocal.Close()
      End If      
    End Try
End Sub
A: 

Use object.refresh

http://www.devx.com/vb2themax/Tip/18646

Joe Pitz
does not work yet. There is no Data Source attached to it. I am populating it manually.
fireBand