如何在 vb.net 中动态引用控件



我正在尝试根据设置与该控件相等的变量来选择一个控件,如下所示:

selectedBox = sender

作为参考,这是我声明 selectedBox 的方式:

Dim selectedBox As PictureBox

我希望做的是这样的:

If selectedBox = picbox then
...

其中 picbox 是传递给函数的图片框。

但是,由于以下原因,这不起作用:

Operator '=' is not defined for types 'PictureBox' and 'PictureBox'

那么我能在这里做什么呢?

你可以

像这样使用Is

If selectedBox Is picbox Then

最新更新