troubleshooting Question

Passing data between forms

Avatar of schnazzer
schnazzer asked on
4 Comments1 Solution653 ViewsLast Modified:
I'm trying my hand at creating a little sql server connection form.. most of which works except where I need to get the passed string back into the combo box on the first form...

here is what I've got.. I have a server select combo box on the first form that has one selection "<Browse for more options...>" that when selected, opens a child form.

on the child form, I have a tree view that when you select a child node and click the button, it should then repopulate the combo box on the parent form..

child form button code:
private void button1_Click(object sender, EventArgs e)
            if (tabControlDatabaseServers.SelectedTab.Name == "tabPageLocalServers")
                string sqlServerReturnValue = this.treeViewLocalDbServers.SelectedNode.ToString();
            else if (tabControlDatabaseServers.SelectedTab.Name == "tabPageNetworkServers")
                string sqlServerReturnValue = this.treeViewNetworkDbServers.SelectedNode.ToString();

here is the parent form partial code:
public void setServer(string sqlServerReturnValue)
            this.comboBoxSqlServerSelect.Text = "";
            this.comboBoxSqlServerSelect.Text = sqlServerReturnValue;
            this.label3.Text = sqlServerReturnValue;

        private void comboBoxSqlServerSelect_SelectedIndexChanged(object sender, EventArgs e)
            // clear the combo box to prevent duplicates
            comboBoxSqlDbSelect.Text = "";

            SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder();
            connectionString.DataSource = comboBoxSqlServerSelect.Text.ToString();

            if (comboBoxSqlServerSelect.Text.ToString() == "<Browse for more options...>")
                frmAdminSqlNetworkConnect sqlNetConn = new frmAdminSqlNetworkConnect(this);

What I get when I pass the value to a lable is "TreeNode: SERVERNAME"

but the combo box still contains "<Browse for more options...>"  when it should have just the server name I select..

I can't see where I've messed up..

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros