访问组合框winforms中的数据 [英] access to data in combobox winforms

查看:61
本文介绍了访问组合框winforms中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i在组合框中有一些数据。

如何在组合框winforms中访问数据?



以下命令无法访问它们:



combobox.Items [i] .tostring();





谢谢。

解决方案

如果你需要从combobox中获取所选项目

 comboBox1.SelectedItem.Text 





获取所有数据

 foreach(comboBox1.Items中的var项)
{
Console.WriteLine(item.ToString());
}



获取更多详细信息

system.windows.forms.combobox(v = vs.110).aspx [ ^ ]


您还可以考虑 SelectedIndex 属性 [ ^ ]。


hello

i have some data in combobox.
how can i access to data in combobox winforms?

the following command can not access to them :

combobox.Items[i].tostring();


thanks.

解决方案

If you need to get selected item from combobox

comboBox1.SelectedItem.Text 



For to get all data

 foreach (var item in comboBox1.Items)
{
 Console.WriteLine(item.ToString());
}


Get more details
system.windows.forms.combobox(v=vs.110).aspx[^]


You can also consider the SelectedIndex property[^].


这篇关于访问组合框winforms中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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