开发者

viewing events in winforms

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜