Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding Index of item in combobox
Message
De
23/01/2003 07:26:07
David Bradford
Georgia Department of Revenue
Lawrenceville, Georgie, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Finding Index of item in combobox
Divers
Thread ID:
00744672
Message ID:
00744672
Vues:
56
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?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform