C# - Getting int value from ComboBox object property -


i'm using windows forms. there way new_object.number_prop value object selected in combobox1? preferably without using combobox1 indexes. appreciated. i've been looking solution while now.

sampleobject new_object = new sampleobject(); new_object.text_prop = "sample text"; new_object.number_prop = 3;  combobox1.items.insert(0, new_object);  class sampleobject {     public string text_prop {get; set; }     public int number_prop {get; set; }     public override string tostring();     {         return text_prop;     } } 

probably talking this:

var selectedobject = (sampleobject) combobox1.selecteditem; var value = selectedobject.number_prop; 

also please note, object reserved word (as alias object class) in c#.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -