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

在做WinForm时,想做一个像Asp.Net里的ImageButton的控件,于是自己写了一个自定义控件,名为:ImageButton,继承PictureBox类,并实现IButtonControl接口,但是实现IButtonControl接口时必须重写IButtonControl的NotifyDefault(bool value) 和 PerformClick()方法,还有 DialogResult { get; set; }属性,我的代码如下,可是里面的PerformClick()方法我不会写,请高手指导一下。

None.gif using  System;
None.gif
using  System.Collections.Generic;
None.gif
using  System.ComponentModel;
None.gif
using  System.Drawing;
None.gif
using  System.Data;
None.gif
using  System.Text;
None.gif
using  System.Windows.Forms;
None.gif
None.gif
namespace  MyControls
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    
public partial class ImageButton : PictureBox,IButtonControl
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
private DialogResult dialogResult;
InBlock.gif
InBlock.gif        
public ImageButton()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            InitializeComponent();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public void PerformClick()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//这里面的代码不会写
ExpandedSubBlockEnd.gif
        }

InBlock.gif
InBlock.gif        
protected override void OnPaint(PaintEventArgs pe)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
// TODO: 在此处添加自定义绘制代码
InBlock.gif
InBlock.gif            
// 调用基类 OnPaint
InBlock.gif
            base.OnPaint(pe);
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public virtual void NotifyDefault(bool value)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
public virtual DialogResult DialogResult
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return this.dialogResult;
ExpandedSubBlockEnd.gif            }

InBlock.gif            
set
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
this.dialogResult = value;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif


 

转载于:https://www.cnblogs.com/wangweijie/archive/2006/12/06/583770.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值