سؤال

I am calling the following on ToolStripMenu item click :

protected void windowNewMenu_Click(object sender, EventArgs e)
    {
     if (_selectedThings.Contains(((ToolStripMenuItem)sender).Tag))
     {
        selectedItemsPropertyGrid.SelectedObject = ((ToolStripMenuItem)sender).Tag;
        selectedItemsComboBox.SelectedText = (((ToolStripMenuItem)sender).Tag.GetType()).ToString();
     }
    }

However the second line that is supposed to change does not seem to produce any visible changes to the ComboBox. Any Suggestions?

هل كانت مفيدة؟

المحلول

SelectedText is for highlighting a portion of the text, not selecting an item in the list. For that, you need SelectedItem.

Or you can just use:

selectedItemsComboBox.Text = ...
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top