gpt4 book ai didi

asp.net - Handles 子句需要在包含类型或其基本类型之一中定义的 WithEvents 变量

转载 作者:行者123 更新时间:2023-12-02 18:20:26 27 4
gpt4 key购买 nike

Protected Sub drp_usertype_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles drp_usertype.SelectedIndexChanged

End Sub

在 drp_usertype.SelectedINdexChanged 下出现错误

它是一个下拉列表

最佳答案

当您声明 drp_usertype 对象时,必须按以下方式完成:

Private WithEvents drp_usertype As DropDownList

这与

相同
Private WithEvents drp_usertype As New DropDownList

等等...

WithEvents 关键字允许控件使用 Handles 语法与其所有者 Hook 事件。在设计器中添加组件时,它会自动为您生成此组件,但在您自己创建组件时,如果您打算在组件中使用事件,则必须包含 WithEvents

如果您没有声明对象 WithEvents,则必须像在 C# 中那样使用 AddHandler 以编程方式分配处理程序 - 请参阅:AddHandler

关于asp.net - Handles 子句需要在包含类型或其基本类型之一中定义的 WithEvents 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15812648/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com