济南做网站互联网公司,四川可以做宣传的网站,国内自动化网站建设,做外汇的官方网站在做WinForm时#xff0c;想做一个像Asp.Net里的ImageButton的控件#xff0c;于是自己写了一个自定义控件#xff0c;名为#xff1a;ImageButton#xff0c;继承PictureBox类#xff0c;并实现IButtonControl接口#xff0c;但是实现IButtonControl接口时必须重写IBut…在做WinForm时想做一个像Asp.Net里的ImageButton的控件于是自己写了一个自定义控件名为ImageButton继承PictureBox类并实现IButtonControl接口但是实现IButtonControl接口时必须重写IButtonControl的NotifyDefault(bool value) 和 PerformClick()方法还有 DialogResult { get; set; }属性我的代码如下可是里面的PerformClick()方法我不会写请高手指导一下。 using System;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() { //这里面的代码不会写 } protected override void OnPaint(PaintEventArgs pe) { // TODO: 在此处添加自定义绘制代码 // 调用基类 OnPaint base.OnPaint(pe); } public virtual void NotifyDefault(bool value) { } public virtual DialogResult DialogResult { get { return this.dialogResult; } set { this.dialogResult value; } } }} 转载于:https://www.cnblogs.com/wangweijie/archive/2006/12/06/583770.html