使用数组或集合作为usercontrol属性? [英] Use an array or collection as a usercontrol property?

查看:64
本文介绍了使用数组或集合作为usercontrol属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在我的用户控件上指定一个公共属性,以容纳三个

不同的图像。我弄清楚如何做到这一点并且谷歌搜索不是帮助。 (我可能不是在正确的条件下搜索。)


我的下面的示例是使用图像数组,但我不能指定多于

一个参数在SET语句中。我不知道怎么改变这个使用

a图像集。


....

私人iImages(2)as image''持有三张图片

....


''为特定州设置/返回图像

公共财产图片(ByVal index As Integer)图片

获取

返回iImages(索引)

结束获取

设置(ByVal索引为整数,ByVal值为图像)''< ---不起作用。

如何指定索引

iImages(索引)=值

如果iIndex = index那么''如果更改当前显示图像的图像,

将其应用于显示

picImage.Image = Value

结束如果

结束集

结束物业

Trying to specify a single public property on my user control to hold three
different images. I figure out how to do this and Google searches are not
helping. (I probably am not searching on the right terms.)

My sample below is using an array of images, but I cannot specify more than
one parameter in the SET statement. I''m not sure how I''d change this to use
a collection of images.

....
Private iImages(2) as image ''Holds three images
....

''Set/Return image for particular state
Public Property image(ByVal index As Integer) As image
Get
Return iImages(index)
End Get
Set(ByVal index as Integer, ByVal Value As image) ''<---Doesn''t work. How
do I specify an index
iImages(index) = Value
If iIndex = index Then ''If changing image for currently displayed image,
apply it to display
picImage.Image = Value
End If
End Set
End Property

推荐答案

No Nozer,


我想你有制作2个房产,

一个用于设置索引,一个用于您想要返回的图像

或某些功能


我会选择2个属性,然后图像是只读的


我希望这有帮助吗?


Cor
Hi Noozer,

I think you have to make 2 properties,
one to set your index and one for the image you want to have returned
Or some functions

I would choose for the 2 properties and then the image is readonly

I hope this helps?

Cor
尝试在我的用户控件上指定一个公共属性来保存
三个不同的图像。我弄清楚如何做到这一点,谷歌搜索并没有帮助。 (我可能没有在正确的条件下搜索。)

下面我的示例使用的是图像数组,但是我不能在SET语句中指定比
更多的参数。我不知道我怎么把它更改为
使用一组图像。

...
私人iImages(2)作为图像''持有三个图像
...

''为特定状态设置/返回图像
公共属性图像(ByVal index As Integer)作为图像
获取
返回iImages(索引)
结束获取
设置(ByVal索引为整数,ByVal值为图像)''< ---不起作用。如何指定索引
iImages(索引)=值
如果iIndex = index则''如果更改当前显示的
图像的图像,请将其应用于显示
picImage.Image = Value
结束如果
结束设置
Trying to specify a single public property on my user control to hold three different images. I figure out how to do this and Google searches are not
helping. (I probably am not searching on the right terms.)

My sample below is using an array of images, but I cannot specify more than one parameter in the SET statement. I''m not sure how I''d change this to use a collection of images.

...
Private iImages(2) as image ''Holds three images
...

''Set/Return image for particular state
Public Property image(ByVal index As Integer) As image
Get
Return iImages(index)
End Get
Set(ByVal index as Integer, ByVal Value As image) ''<---Doesn''t work. How
do I specify an index
iImages(index) = Value
If iIndex = index Then ''If changing image for currently displayed image, apply it to display
picImage.Image = Value
End If
End Set
End Property



必须是一种让它看起来像一个像VB.Net这样的集合的方法。

在控制中做它。


" Cor" < no*@non.com>写在消息

新闻:Op ************** @ TK2MSFTNGP09.phx.gbl ...
There has to be a way to make it appear as a collection like VB.Net''s built
in controls do it.

"Cor" <no*@non.com> wrote in message
news:Op**************@TK2MSFTNGP09.phx.gbl...
嗨Noozer,

我认为你必须制作2个属性,
一个设置你的索引,一个用于你想要返回的图像
或者一些功能

我会选择2个属性然后图像是只读的

我希望这有帮助吗?

Hi Noozer,

I think you have to make 2 properties,
one to set your index and one for the image you want to have returned
Or some functions

I would choose for the 2 properties and then the image is readonly

I hope this helps?

Cor
试图指定一个我的用户控件上的单个公共属性来保存
Trying to specify a single public property on my user control to hold


三个

不同的图像。我弄清楚如何做到这一点,谷歌搜索是
没有帮助。 (我可能没有在正确的条件下搜索。)

我的下面的示例使用的是图像数组,但我不能指定更多
different images. I figure out how to do this and Google searches are not helping. (I probably am not searching on the right terms.)

My sample below is using an array of images, but I cannot specify more


而不是

SET语句中的一个参数。我不知道怎么把它改成
one parameter in the SET statement. I''m not sure how I''d change this to


使用

一组图像。

...
私有iImages(2)作为图像''保存三张图像
...

''为特定状态设置/返回图像
公共属性图像(ByVal index As Integer)作为图像获取
返回iImages(索引)
结束获取
设置(ByVal索引为整数,ByVal值为图像)''< ---不起作用。
如何指定索引
iImages(索引)=值
如果iIndex = index则''如果更改当前显示的图像
a collection of images.

...
Private iImages(2) as image ''Holds three images
...

''Set/Return image for particular state
Public Property image(ByVal index As Integer) As image
Get
Return iImages(index)
End Get
Set(ByVal index as Integer, ByVal Value As image) ''<---Doesn''t work. How do I specify an index
iImages(index) = Value
If iIndex = index Then ''If changing image for currently displayed


图像,

将其应用于显示
picImage.Image = Value
结束如果
结束设置
结束属性
apply it to display
picImage.Image = Value
End If
End Set
End Property




FWIW ...我通过将我的属性定义为

图像列表来实现其功能。


仍然不是我想要的,因为我需要一个单独的图像集合

可能是不同的大小。


我知道我是在这里遗漏了一些非常基本的东西而且我不能把它钉下来!

谈论令人沮丧的事!


:)

" Noozer" < PO ******** @ 127.0.0.1>在消息中写道

news:GUxIb.877073
FWIW... I sortof have the functionality by defining my property as an
imagelist.

Still not what I want though as I need a collection of individual images
that could be different sizes.

I know I''m missing something very basic here and I just can''t nail it down!
Talk about frustrating!

: )
"Noozer" <po********@127.0.0.1> wrote in message
news:GUxIb.877073


这篇关于使用数组或集合作为usercontrol属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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