如何在Visual Studio中为自定义控件设置要编辑的默认事件? [英] How can I set the default event to be edited for my custom control in Visual Studio?

查看:147
本文介绍了如何在Visual Studio中为自定义控件设置要编辑的默认事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过继承Button类制作了一个自定义按钮。当我双击设计器中的自定义按钮时,它会使MyButton.Click的事件处理功能:

I made a custom button by inheriting the Button class. When I double click the custom button in Designer, it makes the event handling function for MyButton.Click:

Private Sub MyButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyButton1.Click

    End Sub

我如何做到这一点,当您双击时,它会使事件处理功能为另一个事件?例如,MyButton.KeyUp:

How can I make it so that when you double click, it makes the event handling function for another event? For example, MyButton.KeyUp:

Private Sub MyButton1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyButton1.KeyUp

    End Sub

希望有人可以帮助我这个。

Hopefully, someone can help me with this.

推荐答案

使用 DefaultEventAttribute

<DefaultEvent("KeyUp")> Public Class MyButton

这篇关于如何在Visual Studio中为自定义控件设置要编辑的默认事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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