Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding Index of item in combobox
Message
From
23/01/2003 07:26:07
David Bradford
Georgia Department of Revenue
Lawrenceville, Georgia, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
Finding Index of item in combobox
Miscellaneous
Thread ID:
00744672
Message ID:
00744672
Views:
55
How do I set a combobox to a specific item in the
list based on the value of the ValueMember for that
item?

Scenario: user double clicks row in grid for editing.
App creates and populates myCar object from selected
record in grid.

myCar.VehicleID = 7;
myCar.VehicleType = 3;
myCar.Name = "Corolla";

Next an edit form is created and populated with

existing values for the Car object.

frmEditVehicle.txtName = myCar.Name;
frmEditVehicle.txtID = myCar.ID;

NOTE: at this point all vehicle types have already
been loaded into the cboVehicleType combobox.

frmEditVehicle.cboVehicleType.SelectedIndex = ???;

What I know here is that the ValueMember for the item
in the combobox that I want to select is 3. However,
the Index number for the item may be 2, or something
else. What is the best-practice method for doing this
in .NET?
Next
Reply
Map
View

Click here to load this message in the networking platform