开发者

viewing events in winforms

开发者 https://www.devze.com 2023-02-20 02:37 出处:网络
How can I choose which event is shown when I double click on a control in winforms designer? For example, winforms shows the \"TextChang开发者_如何转开发ed\" event when I double click on a textbox. I

How can I choose which event is shown when I double click on a control in winforms designer?

For example, winforms shows the "TextChang开发者_如何转开发ed" event when I double click on a textbox. If I wanted to make it show the "GotFocus" event, how could I do that? I am guessing I would inherit textbox and set some property, but I cant find that property.


Replace the [DefaultEvent] attribute by inheriting from the control:

using System;
using System.ComponentModel;
using System.Windows.Forms;

[DefaultEvent("GotFocus")]
class MyTextBox : TextBox { 
}


The deafult event is defined with DefaultEventAttribute class. So unless you have access to the control code, you cant change existing ones.

By inheriting you can by using that attribute.

0

精彩评论

暂无评论...
验证码 换一张
取 消