简体   繁体   中英

C# combo box issue

I have a combo box of items that I fill with the OUs in a container. What I want to do is 2 things. One set the value of my OU variable to the item chosen from the OU list and 2 update a textbox field in the GUI to use this dropdown value.

This is what I am trying to do:

    private void oulist_SelectionChangeCommitted(object sender, EventArgs e)
    {
        oulist.SelectedValue = txtboxOU.Text;
        sou= oulist.SelectedValue;

     }

I can't get this to work with SelectedValueChanged or the SelectionChangeCommitted event. How would I go about doing this?

SelectedValueChanged is very probably the event you want to use here, but from your description of what you want to do, I'd expect to see:

txtboxOU.Text = oulist.SelectedValue;

rather than

oulist.SelectedValue = txtboxOU.Text;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM