Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox Question
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01352049
Message ID:
01352058
Views:
25
>>I'm loading a ComboBox:
>>
>>
>>cboType.Items.Add("Book");
>>cboType.Items.Add("CD");
>>cboType.Items.Add("DVD");
>>cboType.Items.Add("Periodical");
>>cboType.Items.Add("Tape");
>>
>>
>>The I want to set it's selected index:
>>
>>
>>cboType.SelectedIndex = iItem;
>>
>>
>>This errors because cboType.Items.Count is zero.
>>
>>What's wrong here?
>
>That should work. It sounds like a timing issue - are you attempting to set the SelectedIndex before the items have been added? Or is iItem larger than the # of items in the collection (ex. you try to set SelectedIndex to 5 but the highest you can actually set it to is 4 because C# uses 0 based arrays?)

That's exactly the problem - Items.Count is zero. The combo is loaded in the form's Load. The SelectedIndex is being set in a Setup method called later.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform