将组合框中的选定项转换为字符串 [英] Convert selected item in combobox into string

查看:182
本文介绍了将组合框中的选定项转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码尝试获取组合框中的选定项目并将其转换为字符串。但是在我运行我的项目后,它没有像我预期的那样显示值。以下是我的代码:



Hi, I have the following codes which is trying get the selected item in combobox and convert it into string. But after I run my project it does not display the value as I expected. Below are my codes:

dummyMeasurementDto.ProcessType = cmbProcessType.SelectedItem.ToString();

推荐答案

尝试..

Try..
dummyMeasurementDto.ProcessType = cmbProcessType.SelectedItem.Text.ToString();
//OR
dummyMeasurementDto.ProcessType = cmbProcessType.Text;







Object selectedItem = comboBox1.SelectedItem;
String str=selectedItem.ToString();


这篇关于将组合框中的选定项转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆