VB Windows APP:ComboBox SelectedValue [英] VB Windows APP: ComboBox SelectedValue

查看:71
本文介绍了VB Windows APP:ComboBox SelectedValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题听起来有点疯狂但.........如何在ComboBox中设置所选项?


我填充了一个ComboBox有一堆自定义私有类的实例:

This question is going to sound a little crazy but.........How do you set the selected item in a ComboBox?

I am populating a ComboBox with a bunch of instances of a custom private class:

展开 | 选择 | Wrap | 行号

推荐答案

您好Frinny,

你的意思是在.NET发布吗? :-)


博士B
Hi Frinny,

Did you mean to post this in .NET? :-)

Dr B



嗨Frinny,

你的意思是在.NET中发布这个吗? :-)


博士B
Hi Frinny,

Did you mean to post this in .NET? :-)

Dr B



>> blush<<


我必须停止这样做!


(特别是因为这个问题与网站开发无关!)


-Frinny

>>blush<<

I gotta stop doing that!

(especially since this question has nothing to do with web development!)

-Frinny


你在做什么似乎应该使用SelectedValue,不知道为什么它不会。

你能否切换到一个字典< IDType,东西>收集并将其设置为您的数据源(或类似的东西。然后您可以使用ID引用字典并将项目设置为SelectedItem?


当组合框只是字符串,我使用.Items.Contains(我想要的字符串值)


当组合框使用数据源时(我的数据源总是DataTables,对不起),我不得不跳过一些篮球。
What you are doing seems like it should work with the SelectedValue, not sure why it doesn''t.
Are you able to maybe switch to a Dictionary<IDType,Something> collection and set it as your data source (or something like that instead. Then you can reference the Dictionary with the ID and get the item to set to SelectedItem?

When the combobox is just strings, I use the .Items.Contains("string value I want")

When the combobox uses a datasource (mine are always DataTables, sorry), I had to jump through some hoops.
展开 | 选择 | Wrap | 行号


这篇关于VB Windows APP:ComboBox SelectedValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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