[CLOSED] Select the firt item in a ComboBox?

  1. #1

    [CLOSED] Select the firt item in a ComboBox?

    I have the following Combobox and I need the first item to be selected:

    X.ComboBox()
                                    .ID("yearComboBox")
                                    .Editable(false)
                                    .Flex(1)
                                    .FieldLabel("Year")
                                    .QueryMode(DataLoadMode.Local)
                                    .TriggerAction(TriggerAction.All)
    
                                    )
                                    .Items(
                                             items =>
                                             {
                                                 for (int i = DateTime.Today.Year; i > DateTime.Today.Year - 10; i--)
                                                 {
                                                     var yearItem = new ListItem(i.ToString());
                                                     items.Add(yearItem);
                                                 }
                                             }
                                    )
    I don't want to use
    .SelectedItems(new ListItem("2014"))
    because obviously this is not going to work in the future.

    Isn't there a easy way to select the first item using the Index of the item????
    Last edited by Daniil; Sep 27, 2014 at 7:55 AM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    Hi

    Please use that code
     .SelectedItems(new ListItem{ Index = 0 })
  3. #3
    Great, thanks.

Similar Threads

  1. ComboBox select a item by index
    By rookie in forum 1.x Help
    Replies: 1
    Last Post: Dec 15, 2012, 2:07 AM
  2. I can not select any item in combobox
    By marco.amusquivar in forum 1.x Help
    Replies: 1
    Last Post: Mar 21, 2012, 8:09 PM
  3. [CLOSED] Combobox, select first item
    By Yevgeniy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 28, 2011, 12:05 PM
  4. Replies: 0
    Last Post: Sep 20, 2010, 8:56 PM
  5. Select a item in a Combobox
    By eliezer in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2009, 12:23 PM

Posting Permissions