Click here to Skip to main content
15,908,841 members
Home / Discussions / C#
   

C#

 
QuestionHow to override Button Click EventArgs or use another ways to achieve it? Pin
mctramp16817-Feb-09 21:10
mctramp16817-Feb-09 21:10 
AnswerRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
dan!sh 17-Feb-09 21:33
professional dan!sh 17-Feb-09 21:33 
GeneralRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
mctramp16817-Feb-09 22:40
mctramp16817-Feb-09 22:40 
GeneralRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
Guffa17-Feb-09 23:19
Guffa17-Feb-09 23:19 
GeneralRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
dan!sh 18-Feb-09 2:10
professional dan!sh 18-Feb-09 2:10 
GeneralRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
mctramp16818-Feb-09 14:02
mctramp16818-Feb-09 14:02 
AnswerRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
Luc Pattyn18-Feb-09 2:54
sitebuilderLuc Pattyn18-Feb-09 2:54 
AnswerRe: How to override Button Click EventArgs or use another ways to achieve it? [modified] Pin
DaveyM6918-Feb-09 0:45
professionalDaveyM6918-Feb-09 0:45 
You can do something like this and use the MyButton in place of the in built one wherever you need this functionality:
public class MyButton : Button
{
    public new event EventHandler<ButtonClickEventArgs> Click;

    public new void PerformClick()
    {
        PerformClick(false);
    }
    public void PerformClick(bool value)
    {
        OnClick(new ButtonClickEventArgs(value));
    }

    protected override void OnClick(EventArgs e)
    {
        OnClick(new ButtonClickEventArgs(false));
    }

    protected virtual void OnClick(ButtonClickEventArgs e)
    {
        EventHandler<ButtonClickEventArgs> eh = Click;
        if (eh != null)
            eh(this, e);
    }
}
public class ButtonClickEventArgs : EventArgs
{
    private bool m_Value;

    public ButtonClickEventArgs(bool value)
    {
        m_Value = value;
    }
    public bool Value
    {
        get { return m_Value; }
    }
}

Edited to get generic < > to display!

Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

modified on Wednesday, February 18, 2009 7:18 AM

GeneralRe: How to override Button Click EventArgs or use another ways to achieve it? Pin
mctramp16818-Feb-09 15:00
mctramp16818-Feb-09 15:00 
Question.exe file creation Pin
aratireddy17-Feb-09 20:20
aratireddy17-Feb-09 20:20 
AnswerRe: .exe file creation Pin
N a v a n e e t h17-Feb-09 20:34
N a v a n e e t h17-Feb-09 20:34 
AnswerRe: .exe file creation Pin
Vimalsoft(Pty) Ltd17-Feb-09 21:46
professionalVimalsoft(Pty) Ltd17-Feb-09 21:46 
QuestionSQL Server, client-server connection Pin
MozhdehQeraati17-Feb-09 20:16
MozhdehQeraati17-Feb-09 20:16 
QuestionIIS Pin
MozhdehQeraati17-Feb-09 20:10
MozhdehQeraati17-Feb-09 20:10 
AnswerRe: IIS Pin
Vimalsoft(Pty) Ltd17-Feb-09 21:47
professionalVimalsoft(Pty) Ltd17-Feb-09 21:47 
QuestionFileStream write into file Pin
AndieDu17-Feb-09 19:35
AndieDu17-Feb-09 19:35 
AnswerRe: FileStream write into file Pin
N a v a n e e t h17-Feb-09 20:39
N a v a n e e t h17-Feb-09 20:39 
AnswerRe: FileStream write into file Pin
musefan17-Feb-09 22:04
musefan17-Feb-09 22:04 
GeneralRe: FileStream write into file Pin
Ennis Ray Lynch, Jr.18-Feb-09 3:57
Ennis Ray Lynch, Jr.18-Feb-09 3:57 
GeneralRe: FileStream write into file Pin
musefan18-Feb-09 4:24
musefan18-Feb-09 4:24 
GeneralRe: FileStream write into file Pin
Ennis Ray Lynch, Jr.18-Feb-09 4:32
Ennis Ray Lynch, Jr.18-Feb-09 4:32 
GeneralRe: FileStream write into file Pin
musefan18-Feb-09 7:04
musefan18-Feb-09 7:04 
GeneralRe: FileStream write into file Pin
Ennis Ray Lynch, Jr.18-Feb-09 7:13
Ennis Ray Lynch, Jr.18-Feb-09 7:13 
GeneralRe: FileStream write into file Pin
musefan18-Feb-09 7:24
musefan18-Feb-09 7:24 
QuestionSplit a Zip into smaller zip file of Size 1MB using .NET console application VS 2005 Pin
Member 322226417-Feb-09 19:33
Member 322226417-Feb-09 19:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.