PDA

View Full Version : [CLOSED] Combobox.SelectedItem.Index doesn't work everytime



profitsistemas
Feb 01, 2013, 10:20 PM

Baidaly
Feb 02, 2013, 2:16 AM
Hello!

Can you provide simplified sample of your problem?

http://forums.ext.net/showthread.php?3440

profitsistemas
Feb 02, 2013, 2:10 PM

Baidaly
Feb 03, 2013, 1:26 AM
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;
}

profitsistemas
Feb 03, 2013, 2:02 AM
Thank you! Using Selecteditems.Clear() makes it work ok.

Daniil
Feb 04, 2013, 5:11 AM
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.