Popup Form Refresh combobox on parent form

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Mar 2005
Posts: 65
Reputation: cpopham is an unknown quantity at this point 
Solved Threads: 0
cpopham cpopham is offline Offline
Junior Poster in Training

Popup Form Refresh combobox on parent form

 
0
  #1
May 31st, 2008
I have a parent form that has a combobox. Whn the form loads I get the data from the db and bind to the combobox. that works fine and here is the code I use in form load to cause this to happen:

  1. conn.Open()
  2. cmd.Connection = conn
  3. da = New SqlCeDataAdapter(cmd1, conn)
  4.  
  5. cmd.CommandText = "SELECT * FROM AccountType ORDER BY AcctType"
  6. da2 = New SqlCeDataAdapter(cmd)
  7. da2.Fill(dtAcctType)
  8.  
  9. cmd.CommandText = chkSQL
  10. daCk = New SqlCeDataAdapter(chkSQL, conn)
  11. daCk.Fill(dtChk)
  12.  
  13.  
  14.  
  15. cboType.DataSource = dtAcctType
  16. cboType.DisplayMember = "AcctType"
  17. cboType.ValueMember = "AcctTypeID"
  18. cboType.SelectedIndex = 0

Now if there is not an Account Type, I have a button that will pull up a small form to allow the addition of an account type. The popup form adds the data back to the database just fine, but I am now trying to get the combobox to refresh its data. So I call a public Sub that is located in the parent form to from the popup form to accomplish this task and I have walked the code and the sub is called and appears to work correctly, but the new data never appears in the combobox. Here is my public sub that i call to try and refresh the combobox on the parent form.

  1. Dim dtType As New DataTable
  2. Dim daType As SqlCeDataAdapter
  3.  
  4.  
  5. Try
  6. conn = New SqlCeConnection("Data Source=C:\Program Files\HomeComplete\Data\HomeComplete.sdf")
  7. Catch
  8. End Try
  9.  
  10. Dim cmd As New SqlServerCe.SqlCeCommand
  11.  
  12. cmd.Connection = conn
  13.  
  14. cmd.CommandText = "SELECT * FROM AccountType ORDER BY AcctType"
  15. daType = New SqlCeDataAdapter(cmd)
  16.  
  17. daType.Fill(dtType)
  18. cboType.Items.Clear()
  19. cboType.DataSource = dtType
  20. cboType.DisplayMember = "AcctType"
  21. cboType.ValueMember = "AcctTypeID"
  22. cboType.SelectedIndex = 0
  23. cboType.Refresh()
  24.  
  25.  
  26. conn.Close()

But when I go back to the parent form, the combobox is not updated with the new account. How can i get the combobox to refresh from the database with the new data?

Thank You, Chester
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 252
Reputation: ProfessorPC is an unknown quantity at this point 
Solved Threads: 27
ProfessorPC ProfessorPC is offline Offline
Posting Whiz in Training

Re: Popup Form Refresh combobox on parent form

 
0
  #2
May 31st, 2008
i have used something as easy as in the click event where you add your data on the second form just add
  1. frmOther.refresh
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 65
Reputation: cpopham is an unknown quantity at this point 
Solved Threads: 0
cpopham cpopham is offline Offline
Junior Poster in Training

Re: Popup Form Refresh combobox on parent form

 
0
  #3
May 31st, 2008
I tried that and also on the Public sub that is in the parent form I put it there as well, but it is still not working...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC