组合框和列表框项目 [英] combobox and listbox items

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

问题描述

大家好,


如果你想在一个组合中拥有自己的类,你可以覆盖tostring

函数来显示文本。(得到了一个在这里2; p)

但我似乎没有找到如何获得价值,我必须使用w函数

覆盖工作值?

int = cbo.selectedValue(此类事情)


Tnx


Eric

解决方案

" EricJ" < ER ******** @ ThiSbitconsult.be.RE> schrieb


如果你想在一个组合中拥有你自己的类,你可以覆盖
tostring函数来显示文本。(在这里得到一个2; p)
但我似乎没有找到如何获得价值,我有什么功能来覆盖工作的价值?
int = cbo.selectedValue(这种事情)




我的intellisense提供其他Selected *项目。 ;)其中,有

SelectedItem。 SelectedValue的Memberinfo也显示它返回由ValueMember属性设置的成员的

值 - 使用反射所以

而不是我会使用

directcast(cbo.selecteditem,yourclass).property

-

Armin


如何报价以及原因:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/ news / learn2quote.html


" EricJ" < ER ******** @ ThiSbitconsult.be.RE> schrieb


如果你想在一个组合中拥有你自己的类,你可以覆盖
tostring函数来显示文本。(在这里得到一个2; p)
但我似乎没有找到如何获得价值,我有什么功能来覆盖工作的价值?
int = cbo.selectedValue(这种事情)




我的intellisense提供其他Selected *项目。 ;)其中,有

SelectedItem。 SelectedValue的Memberinfo也显示它返回由ValueMember属性设置的成员的

值 - 使用反射所以

而不是我会使用

directcast(cbo.selecteditem,yourclass).property

-

Armin


如何报价以及原因:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/ news / learn2quote.html


这就是我现在正在做但有一个问题,你不能把cbo设置为一个值。

您总是需要文本来设置cbo。应该可以有一个值

2.

在asp.net中有一个listitem类system.web.UI.WebControls.listitem w

这个类可能,所以应该可以在你自己的

类2中使用它。

我知道我可以解决它但我正在修改我的我们在这里使用的自定义类

并希望包含一个值。未来可能会有更多的事情,但我仍然在尝试这些事情。


这不是一件紧急事情,我一直在烦扰我;)


Tnx看看它。


eric


" Armin Zingler" < AZ ******* @ freenet.de>在消息中写道

news:40 *********************** @ news.freenet.de ...

EricJ < ER ******** @ ThiSbitconsult.be.RE> schrieb


如果你想在一个组合中拥有你自己的类,你可以覆盖
tostring函数来显示文本。(在这里得到一个2; p)
但我似乎没有找到如何获得价值,我有什么功能来覆盖工作的价值?
int = cbo.selectedValue(这种事情)



我的intellisense提供其他Selected *项目。 ;)其中,有
SelectedItem。 SelectedValue的Memberinfo还显示它返回由ValueMember属性设置的成员的
值 - 使用反射所以
而不是我将使用
directcast(cbo.selecteditem,yourclass).property

-
Armin

如何报价以及原因:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



Hi all,

If you want to have your own class in a combo you override the tostring
function to display the text.(got that one here 2 ;p)
But i don''t seem to find how to get the value, w function do i have to
override to work w the values ?
int = cbo.selectedValue (this sort of thing)

Tnx

Eric

解决方案

"EricJ" <er********@ThiSbitconsult.be.RE> schrieb


If you want to have your own class in a combo you override the
tostring function to display the text.(got that one here 2 ;p)
But i don''t seem to find how to get the value, w function do i have
to override to work w the values ?
int = cbo.selectedValue (this sort of thing)



My intellisense offers other Selected* items. ;) Among them, there is
SelectedItem. Memberinfo for SelectedValue also shows that it returns the
value of the member set by the ValueMember property - uses reflection so
instead I''d use
directcast(cbo.selecteditem, yourclass).property
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


"EricJ" <er********@ThiSbitconsult.be.RE> schrieb


If you want to have your own class in a combo you override the
tostring function to display the text.(got that one here 2 ;p)
But i don''t seem to find how to get the value, w function do i have
to override to work w the values ?
int = cbo.selectedValue (this sort of thing)



My intellisense offers other Selected* items. ;) Among them, there is
SelectedItem. Memberinfo for SelectedValue also shows that it returns the
value of the member set by the ValueMember property - uses reflection so
instead I''d use
directcast(cbo.selecteditem, yourclass).property
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


thats w im doing now but it has 1 problem, you can''t set the cbo to a value.
You always need the text to set a cbo. It should be possible to have a value
2.
In asp.net there is a listitem class system.web.UI.WebControls.listitem w
this class its possible, so it should be possible to have this in your own
class 2.
I know i can work around it but i am revising my custom classes we use here
and want to include a value. Probably some more things in the future but im
still experimenting w these things.

Its not an urgent matter, yust bugging me ;)

Tnx for having a look at it.

eric

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40***********************@news.freenet.de...

"EricJ" <er********@ThiSbitconsult.be.RE> schrieb


If you want to have your own class in a combo you override the
tostring function to display the text.(got that one here 2 ;p)
But i don''t seem to find how to get the value, w function do i have
to override to work w the values ?
int = cbo.selectedValue (this sort of thing)



My intellisense offers other Selected* items. ;) Among them, there is
SelectedItem. Memberinfo for SelectedValue also shows that it returns the
value of the member set by the ValueMember property - uses reflection so
instead I''d use
directcast(cbo.selecteditem, yourclass).property
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html



这篇关于组合框和列表框项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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