[CLOSED] Combobox.SelectedItem.Index doesn't work everytime

  1. #1

    [CLOSED] Combobox.SelectedItem.Index doesn't work everytime

    Last edited by Baidaly; Feb 03, 2013 at 1:07 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Can you provide simplified sample of your problem?

    http://forums.ext.net/showthread.php?3440
    Last edited by Baidaly; Feb 02, 2013 at 1:20 AM.
  3. #3
    Last edited by profitsistemas; Feb 02, 2013 at 1:17 PM.
  4. #4
    OK, try to clear selected items before selecting by index:

    switch (entities.ElementAt(0).TypeId)
    {
       case 1:
    	   this.panLoads.Hidden = false;
    	   cboTipo.SelectedItems.Clear();
    	   cboCargas.SelectedItems.Clear();
    	   
    	   this.cboTipo.SelectedItem.Index = 0;
    	   if (entities.ElementAt(0).ResourceId > 2)
    	   {
    		   index = 2;
    	   }
    	   else
    	   {
    		   index = 0;
    	   }
    	   this.cboCargas.SelectedItem.Index = index;
    	   this.cboCargas.UpdateSelectedItems();
    	   break;               
       case 4:
    	   this.panSql.Hidden = false;
    	   this.cboTipo.SelectedItems.Clear();
    	   this.cboConexion.SelectedItems.Clear();
    	   
    	   this.cboTipo.SelectedItem.Index = 1;
    	   this.txtSQL.Text = entities.ElementAt(0).Description;
    	   if (entities.ElementAt(0).ResourceId > 2)
    	   {
    		   index = 3;
    	   }
    	   else
    	   {
    		   index = 1;
    	   }
    	   this.cboConexion.SelectedItem.Index = index;
    	   this.cboConexion.UpdateSelectedItems();
    	   break;
    }
  5. #5
    Thank you! Using Selecteditems.Clear() makes it work ok.
  6. #6
    Hello,

    Just to clarify why a Clear call is required.

    The SelectedItems and SelectedItem properties are used in two ways:

    1. It contains submitted client side selected items.

    2. It is used to select items from server side. In this case the submitted items should be cleared before setting up any new items either for SelectedItems or SelectedItem properties.

Similar Threads

  1. Replies: 1
    Last Post: Aug 24, 2012, 8:55 PM
  2. Replies: 1
    Last Post: Dec 06, 2011, 3:07 AM
  3. [CLOSED] Doesn't work ToolTips for ComboBox Items
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 15, 2011, 3:30 PM
  4. [CLOSED] ComboBox SetValue doesn't change SelectedItem.Text
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 11, 2010, 9:11 AM
  5. Replies: 0
    Last Post: May 22, 2009, 7:59 AM

Tags for this Thread

Posting Permissions