Ticket T171836
Visible to All Users

How to select an item in ComboBoxEdit

created 10 years ago

[DevExpress Support Team: CLONED FROM A1402: Can SelectedIndex be set for RepositoryItemComboBox?]
Still I don't understand - once the comboBox has been created, how do I set it to show a specific value from the list? I do not see a "selectedItem" property.

Answers approved by DevExpress Support

created 10 years ago

Hi,

Do you use ComboBoxEdit in the Standalone or In-Place mode? If it's the first case, ComboBoxEdit provides the SelectedItemSelectedIndex, and EditValue properties to set an edit value. If it's the second case, as stated in the Can SelectedIndex be set for RepositoryItemComboBox? KB article, you need to use methods of an editor container.

If that does not help you, elaborate where you use the ComboBoxEdit and when you need to set an edit value.

I look forward to your response.

    Show previous comments (2)
    WS WS
    Wolfgang Schmidt 6 9 years ago

      @demetrius I think i have exactly the same problem
      I have  a context menu and added a ComboBox to it. In the designer file a RepositoryItemComboBox is added as edit to a BarEditItem by devexpress/visual studio. no code with a combobox appears, so it seems to be somewhere in the RepositoryItemComboBox .
      If i add values to the thing i do it by changing the ComboBoxItemCollection collection in  RepositoryItemComboBox.Items
      But i never see a possiblity to say: RepositoryItemComboBox.SelectedIndex = 0;
      Even if i listen to the SelectedIndexChanged event of the  RepositoryItemComboBox i do not see which value is selected - only if i cast the sender to ComboBoxEdit and then look at the EditValue i get some information.
      I think the original poster has the same problem which i have - how to get the ComboBoxEdit of the  RepositoryItemComboBox to just set a selected index.
      Maybe it is totaly easy - but right now it is just time consuming to find out how to set this thing. Why is thee no property like in Combobox?

      WS WS
      Wolfgang Schmidt 6 9 years ago

        ATM i do something which looks cruel,:
        this.BarButtonMenuItem.EditValue = this.RepositoryItemComboBox.Items[0].ToString();

        Nadezhda (DevExpress Support) 9 years ago

          Hello Wolfgang,

          Please review the Can SelectedIndex be set for RepositoryItemComboBox? KB article as Svetlana suggested.
          I hope you find this information useful. Let me know if you have additional questions.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.