实现IButtonControl接口时, PerformClick()方法的代码怎么写,请高手指导!
生活随笔
收集整理的這篇文章主要介紹了
实现IButtonControl接口时, PerformClick()方法的代码怎么写,请高手指导!
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在做WinForm時(shí),想做一個(gè)像Asp.Net里的ImageButton的控件,于是自己寫(xiě)了一個(gè)自定義控件,名為:ImageButton,繼承PictureBox類(lèi),并實(shí)現(xiàn)IButtonControl接口,但是實(shí)現(xiàn)IButtonControl接口時(shí)必須重寫(xiě)IButtonControl的NotifyDefault(bool value) 和 PerformClick()方法,還有 DialogResult { get; set; }屬性,我的代碼如下,可是里面的PerformClick()方法我不會(huì)寫(xiě),請(qǐng)高手指導(dǎo)一下。
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Drawing;
using?System.Data;
using?System.Text;
using?System.Windows.Forms;
namespace?MyControls
{
????public?partial?class?ImageButton?:?PictureBox,IButtonControl
????{
????????private?DialogResult?dialogResult;
????????public?ImageButton()
????????{
????????????InitializeComponent();
????????}
????????public?void?PerformClick()
????????{
????????????//這里面的代碼不會(huì)寫(xiě)
????????}
????????protected?override?void?OnPaint(PaintEventArgs?pe)
????????{
????????????//?TODO:?在此處添加自定義繪制代碼
????????????//?調(diào)用基類(lèi)?OnPaint
????????????base.OnPaint(pe);
????????}
????????public?virtual?void?NotifyDefault(bool?value)
????????{
????????}
????????public?virtual?DialogResult?DialogResult
????????{
????????????get
????????????{
????????????????return?this.dialogResult;
????????????}
????????????set
????????????{
????????????????this.dialogResult?=?value;
????????????}
????????}
????}
}
?
轉(zhuǎn)載于:https://www.cnblogs.com/wangweijie/archive/2006/12/06/583770.html
總結(jié)
以上是生活随笔為你收集整理的实现IButtonControl接口时, PerformClick()方法的代码怎么写,请高手指导!的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 牛客练习赛46 A华华教奕奕写几何 (
- 下一篇: filter_var()函数