加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

vb.net – 如何确定什么类型的对象是事件的发件人?

发布时间:2020-12-17 00:31:16 所属栏目:大数据 来源:网络整理
导读:亲爱的我的子 Dim onThisTable as String ="Name"Private Sub skill_mouseHover(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button1.MouseHover,button2.MouseHover,panel1.MouseHover,panel2.MouseHover,pbox1.MouseHover descri
亲爱的我的子
Dim onThisTable as String ="Name"

Private Sub skill_mouseHover(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles button1.MouseHover,button2.MouseHover,panel1.MouseHover,panel2.MouseHover,pbox1.MouseHover
  descriptionLabel.Text = dbClass.getDescription(sender.Text,onThisTable)
End Sub

现在,我希望根据用户传递的内容(面板或一个pbox或一个按钮)给onThisTable一个不同的值,但是我无法找到什么是正确的方式来比较它是什么类型的?

Private Sub skill_mouseHover(ByVal sender As System.Object,pbox1.MouseHover
  if sender is ( a button )
     onThisTable = "Admin"
  else if sender is ( a panel )
     onThisTable = "dbObject"
  else 
     onThisTable ="Name"
  end if

   descriptionLabel.Text = dbClass.getDescription(sender.Text,onThisTable)
End Sub
您可以在此处使用TypeOf关键字作为描述( link)
If TypeOf sender Is Button Then
        onThisTable = "Admin"
    ElseIf TypeOf sender Is System.Windows.Forms.Panel Then
        onThisTable = "dbObject"
    Else
        onThisTable = "Name"
    End If

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读