Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
コンボボックスに多数のアイテムを表示したいのですが、ユーザーが選択すると、テキストが返される代わりに、そのテキストを参照する特定の値が返されます。これについての助けは大歓迎です。
これは典型的なKey,Valueバインディングです。Dictionaryを例として使用します。したがって、Dictionary に適切な値を入力したと仮定すると、コードは次のようになります。
Key,Value
Dictionary
ComboBox1.DataSource = yourDictionary.ToList ComboBox1.DisplayMember = "Value" ComboBox1.ValueMember = "Key"
次に、プロパティを使用して値を選択できComboBox1.SelectedValueます。
ComboBox1.SelectedValue