【问题标题】:How can I dynamically reference a control in vb.net如何在 vb.net 中动态引用控件
【发布时间】:2018-08-22 17:14:19
【问题描述】:

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

selectedBox = sender

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

Dim selectedBox As PictureBox

我希望做的是这样的:

If selectedBox = picbox then
...

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

但这不起作用,原因是:

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

那么我可以在这里做什么?

【问题讨论】:

    标签: vb.net controls picturebox


    【解决方案1】:

    你可以像这样使用Is

    If selectedBox Is picbox Then
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-27
      • 2014-04-08
      • 1970-01-01
      • 2022-01-16
      • 2011-01-24
      • 2014-02-24
      • 1970-01-01
      相关资源
      最近更新 更多