鲁鲁.Net

导航

实现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;
            }

        }


    }

}


 

posted on 2006-12-06 11:00  鲁鲁  阅读(1048)  评论(3编辑  收藏  举报