Dropdown will not change selected item text after changing options list at runtime

I have a Dropdown UI control. If I clear the options list and repopulate it, the text of the selected item is not changed.

It doesn’t matter where or what the user clicks on, the only way to force the text to change is to alter the value member to a different value, and then put it back. This occurs when there is only one item in the new list, and when there is more than one. I have tried explicitly invoking OnValueChanged() but this still has no effect.

How do I force the Dropdown to reset/repaint/remove whatever caching its got after updating the options list?

I am resetting the options list like so:

    m_branchesDropdown.options.Clear();
    foreach (var branch in m_branches)
    {
        m_branchesDropdown.options.Add(new Dropdown.OptionData() { text = branch.name });
    }

m_branchesDropdown.RefreshShownValue (); worked for me with little extra work to add the value to a string variable, I used string string optionselected = m_branchesDropdown.captionText.text

I had this problem too but this seemed to fix it:

    int TempInt = m_branchesDropdown.value;
    m_branchesDropdown.value = m_branchesDropdown.value+1;
    m_branchesDropdown.value = TempInt;

Just put that after the foreach loop.

There is a function called RefreshShownValue() on the dropdown that should be called.

ddProperty.value = 0;
ddProperty.Select();
ddProperty.RefreshShownValue();

Ok just found the solution to this:

m_branchesDropdown.transform.FindChild("Put_Your_Caption_Text_Here").GetComponent<Text>().text = m_branchesDropdown.options[m_branchesDropdown.value].text;