Hii,
I used XamCombo with Multiple columns, with Silverlight 4 and C#
I want to set Selected Index by giving its value run time in Load event.
normally with other combo Controls we are doing this as,
cmbcategory.text= "0005" or cmbcategory.text= defaultvalue
how can I do this using XAMCombo editor ??
HI,
Try using the selected Item add method.
Here is a code snippet
ObservableCollection<Person> people = new ObservableCollection<Person>();
Person q = new Person() { ID = 2, Name = "mary" };
people.Add(p);
people.Add(q);
people.Add(v);
comboEditor.ItemsSource = people;
comboEditor.DisplayMemberPath =
comboEditor.SelectedItems.Add(q);
Sincerely, Matt Developer Support Engineer
Hi,
I also Having Problem with this Combo box Selected index,
Suppose I load combo editor from WCF Service. people as e.result
comboEditor.ItemsSource = e.result; // result People source as above sample
then I load Nother data List to Grid, as TransactionList as well , bcs user need to double click the grid and Edit Previouse data.
transactionLIst included some other data[ as Transcode,TransName,TransDate,,PersonId] and only ID from Person. when user double click grid I need to set that ID as selected item
currently I can't see any solution other than For Loop. as below
for (int i = 1; i < comboEditor.Items.Count; i++) { if (((Person)cmbFromStore.Items[i].Data).ID == rowdata.ID) // rowdata got from Grid { comboEditor.SelectedIndex = i; break; } }
Are there Any Good Solution other than above method. ???
bcs its Not Good Practice as Performance wise. We use Infragistics Component to get High Performance
I hope u have Good Method to solve this Problem..
please reply.
thx
Hi mcanagey,
sorry for the late response.
I am afraid that XamComboEditor don't provide such functionality. So you have to manually search for the corresponding record into the XamComboBox values.
Perhaps you could use a LINQ expression which will make your code a bit more clean and readable. For example :
comboEditor.SelectedItem = cmbFromStore.Items.Single(item => (item as Person).ID == rowdata.ID);
If you have any performance concerns regarding this approach you could use a Dictionary<ID, Person>.
Hope this help