| | |
Popup Form Refresh combobox on parent form
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Mar 2005
Posts: 65
Reputation:
Solved Threads: 0
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:
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.
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
VB.NET Syntax (Toggle Plain Text)
conn.Open() cmd.Connection = conn da = New SqlCeDataAdapter(cmd1, conn) cmd.CommandText = "SELECT * FROM AccountType ORDER BY AcctType" da2 = New SqlCeDataAdapter(cmd) da2.Fill(dtAcctType) cmd.CommandText = chkSQL daCk = New SqlCeDataAdapter(chkSQL, conn) daCk.Fill(dtChk) cboType.DataSource = dtAcctType cboType.DisplayMember = "AcctType" cboType.ValueMember = "AcctTypeID" 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.
VB.NET Syntax (Toggle Plain Text)
Dim dtType As New DataTable Dim daType As SqlCeDataAdapter Try conn = New SqlCeConnection("Data Source=C:\Program Files\HomeComplete\Data\HomeComplete.sdf") Catch End Try Dim cmd As New SqlServerCe.SqlCeCommand cmd.Connection = conn cmd.CommandText = "SELECT * FROM AccountType ORDER BY AcctType" daType = New SqlCeDataAdapter(cmd) daType.Fill(dtType) cboType.Items.Clear() cboType.DataSource = dtType cboType.DisplayMember = "AcctType" cboType.ValueMember = "AcctTypeID" cboType.SelectedIndex = 0 cboType.Refresh() 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
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
i have used something as easy as in the click event where you add your data on the second form just add
vb.net Syntax (Toggle Plain Text)
frmOther.refresh
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: display network SQL Servers in combobox
- Next Thread: Factorial of N
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic box button buttons center check code component connectionstring convert crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel fade file-dialog firewall folder ftp generatetags hardcopy image images input insert intel isnumericfuntioncall math monitor navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port problem problemwithinstallation project record reports" savedialog searchvb.net select serial shutdown string survey tcp temp temperature text textbox timer toolbox trim updown user useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf





