欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

实现IButtonControl接口时, PerformClick()方法的代码怎么写,请高手指导!

发布时间:2023/12/18 编程问答 64 豆豆
生活随笔 收集整理的这篇文章主要介绍了 实现IButtonControl接口时, PerformClick()方法的代码怎么写,请高手指导! 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

在做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

总结

以上是生活随笔为你收集整理的实现IButtonControl接口时, PerformClick()方法的代码怎么写,请高手指导!的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。