c# - How to test a selected item of a ComboBox is equal to my string? -
i started learning c# week ago. have little experience objective c. give me hard time asking such beginner question.
well, user able select combo box. created combobox visually in xaml. contents of combo box strings. however, when user selects string of choice, store value int can calculations. errors have been can't convert object string , many other conversation errors.
int x; string selvalue = (string)combobox1.selectedvalue; if ((selvalue=="green")||(selvalue=="blue")) { x= 5; }
would best create function accepts object , returns int, if please tell ?
you should have string green selectedtext , value int 5 selectedvalue, way can drop code & int x = (int)combobox1.selectedvalue, give 5. need google winform combobox databinding, you'll see can bind diferent properties text & value.
Comments
Post a Comment