[Help me - get value combobox]

[Help me - get value combobox]

Old forum URL: forums.lhotka.net/forums/t/10202.aspx


linhvu posted on Friday, March 25, 2011

I have one combobox. Combobox Datasource is object NameValueList.

My code: combobox.DataSource = objNameValueList;

When event combobox_DropDownClosed raise, i want to get ValueMember of Combobox but i can't.

And combobox.SelectedItem has Key (1) and Value ("Jack"). I want to get key (1). I can't do it.

Please.

jack.doe77 replied on Friday, March 25, 2011

Can you get the value with

dim cbKey as integer
cbKey = combobox.SelectedValue

linhvu replied on Friday, March 25, 2011

I dont think so. it dont do that.

??? 

Curelom replied on Friday, March 25, 2011

What tech are you using?  ASP.NET?  WPF? Winforms? Silverlight?

Curelom replied on Friday, March 25, 2011

Try casting your combobox.SeletedItem to a NameValuePair and retrieve it from that.

((Csla.NameValueListBase<stringstring>.NameValuePair)myCombo.SelectedItem).Key

linhvu replied on Saturday, March 26, 2011

Thanks so much!

You are Pro.

I can do it.

Curelom

Try casting your combobox.SeletedItem to a NameValuePair and retrieve it from that.

((Csla.NameValueListBase<stringstring>.NameValuePair)myCombo.SelectedItem).Key

 

Copyright (c) Marimer LLC