Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Access value from combo box

$
0
0

I have a combo box defined like below.

cb1.DataSource = new[] { new { Text = "aaaaa", Value = 1 }, new { Text = "bbbbb", Value = 2 }, new { Text = "ccccc", Value = 3 } };
cb1.DisplayMember = "Text";
cb1.ValueMember = "Value";

I have used this before. cb1.SelectedValue does assign the Value (the number) to the table column as I want. I am now in a situation where I need to perform a test on the selected combo box item. I cannot seem to find a way to access the Value. When I step though the program I see there is a property reference for Text and Value, and I have found references for ways of accessing them. I just have not found a way that works. I have also tried creating a List<object>

I'm sure it is just a piece of simple syntax. Thanks in advance.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>