Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
MM .NET Tip 'O The Day
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
MM .NET Tip 'O The Day
Divers
Thread ID:
00814617
Message ID:
00814617
Vues:
44
This isn't specifically an MM .NET tip, but it's a question I've had to answer often.

How do you programmatically select an item in a ComboBox or ListBox? You can do this by setting its SelectedIndex property.

For example, in C#:
this.lstEmployees.SelectedIndex = 1;
And in VB .NET:
Me.lstEmployees.SelectedIndex = 1
If you don't know the index number of the item you want to select, but you know it's text display value, you can use the FindString or FindExactString method to find the item index.

For example, in C#:
this.lstEmployees.SelectedIndex = this.lstEmployees.FindExactString(SelectedText);
And in VB .NET:
Me.lstEmployees.SelectedIndex = Me.lstEmployees.FindExactString(SelectedText)
Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Répondre
Fil
Voir

Click here to load this message in the networking platform