<p>I have a ContextMenu that is displayed after a user right clicks on a ComboBox.  When the user selects an item in the context menu, a form is brought up using the <code>ShowDialog()</code> method. </p>

<pre><code>If frmOptions.ShowDialog() = Windows.Forms.DialogResult.Cancel Then
    LoadComboBoxes()
End If
</code></pre>

<p>When that form is closed, I refresh all the data in the ComboBoxes on the parent form.  However, when this happens the ComboBox that opened the ContextMenu is reset to have a selected index of -1 but the other selected indexes of the other ComboBoxes remain the same.  </p>

<p>How do I prevent the ComboBox that opened the context menu from being reset?</p>

[{'answer_id': 50590, 'author': 'DaveK', 'author_id': 4244, 'author_profile': 'https://Stackoverflow.com/users/4244', 'pm_score': 2, 'selected': True, 'text': "<p>One way to handle this would be to use the context menu's Popup event to grab the selected index of the combobox launching the menu. When the dialog form closes reset the selected index.</p>\n"}, {'answer_id': 50644, 'author': 'Bryan Roth', 'author_id': 299, 'author_profile': 'https://Stackoverflow.com/users/299', 'pm_score': 0, 'selected': False, 'text': '<p>I figured it out.</p>\n\n<p>I created a method that passed the <strong>ContextMenu.SourceControl()</strong> property by reference so I could manipulate the control that called the ContextMenu.  In the beginning of the method, I got the <strong>SelectedValue</strong> of the ComboBox and the reloaded the data in the ComboBoxes.  I then set the <strong>SelectedValue</strong> to the value I had got in the beginning of the method.</p>\n\n<p>Thank you DaveK for pointing me in the right direction.</p>\n'}]
['https://Stackoverflow.com/questions/50565', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/299/']