Click here to Skip to main content
15,905,912 members
Home / Discussions / C#
   

C#

 
GeneralRe: Argument Pin
BabyOreo27-Apr-09 23:52
BabyOreo27-Apr-09 23:52 
GeneralRe: Argument Pin
musefan28-Apr-09 0:45
musefan28-Apr-09 0:45 
AnswerRe: Argument Pin
SeMartens27-Apr-09 22:08
SeMartens27-Apr-09 22:08 
AnswerRe: Argument Pin
N a v a n e e t h27-Apr-09 22:35
N a v a n e e t h27-Apr-09 22:35 
AnswerRe: Argument Pin
12Code27-Apr-09 23:07
12Code27-Apr-09 23:07 
GeneralRe: Argument Pin
BabyOreo27-Apr-09 23:13
BabyOreo27-Apr-09 23:13 
GeneralRe: Argument Pin
Luc Pattyn28-Apr-09 1:10
sitebuilderLuc Pattyn28-Apr-09 1:10 
AnswerRe: Argument [modified] Pin
DaveyM6927-Apr-09 23:13
professionalDaveyM6927-Apr-09 23:13 
You've had some good answers. To add to them, you can't use your derived event args for existing events unless you create your own controls derived from the original.

For example, maybe you want to assign the integer value 1 to the event args passed when a form is loaded. You need to create your own EventArgs and your own Form with a new Load event and override the OnLoad method. Something like this.
using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : IntForm
    {
        public Form1()
        {
            InitializeComponent();
            this.Load += new System.EventHandler<inteventargs>(Form1_Load);
        }

        private void Form1_Load(object sender, IntEventArgs e)
        {
            Console.WriteLine(e.Value);
        }
    }

    public class IntEventArgs : EventArgs
    {
        private int _Value;

        public IntEventArgs(int value)
        {
            _Value = value;
        }
        public IntEventArgs() : this(0) { }

        public static implicit operator IntEventArgs(int value)
        {
            return new IntEventArgs(value);
        }

        /// <summary>
        /// Gets the System.Int32 value held by this IntEventArgs instance.
        /// </summary>
        public int Value
        {
            get { return _Value; }
        }
    }

    public class IntForm : Form
    {
        /// <summary>
        /// Occurs before a form is displayed for the first time.
        /// </summary>
        public new event EventHandler<IntEventArgs> Load;

        protected override void OnLoad(EventArgs e)
        {
            EventHandler<IntEventArgs> eh = Load;
            if (eh != null)
                eh(this, 1);
        }
    }
}


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)
Why are you using VB6? Do you hate yourself? (Christian Graus)

QuestionSomething with a delegate Pin
Joramq27-Apr-09 21:51
Joramq27-Apr-09 21:51 
AnswerRe: Something with a delegate Pin
Christian Graus27-Apr-09 22:07
protectorChristian Graus27-Apr-09 22:07 
GeneralRe: Something with a delegate Pin
Joramq27-Apr-09 22:10
Joramq27-Apr-09 22:10 
AnswerRe: Something with a delegate Pin
OriginalGriff27-Apr-09 22:10
mveOriginalGriff27-Apr-09 22:10 
AnswerRe: Something with a delegate Pin
N a v a n e e t h27-Apr-09 22:38
N a v a n e e t h27-Apr-09 22:38 
GeneralRe: Something with a delegate Pin
Joramq27-Apr-09 23:09
Joramq27-Apr-09 23:09 
GeneralRe: Something with a delegate Pin
N a v a n e e t h28-Apr-09 0:09
N a v a n e e t h28-Apr-09 0:09 
GeneralRe: Something with a delegate Pin
Joramq28-Apr-09 0:17
Joramq28-Apr-09 0:17 
GeneralRe: Something with a delegate Pin
Tom Deketelaere28-Apr-09 1:20
professionalTom Deketelaere28-Apr-09 1:20 
GeneralRe: Something with a delegate Pin
N a v a n e e t h28-Apr-09 1:59
N a v a n e e t h28-Apr-09 1:59 
AnswerRe: Something with a delegate Pin
Luc Pattyn28-Apr-09 1:17
sitebuilderLuc Pattyn28-Apr-09 1:17 
GeneralRe: Something with a delegate Pin
Joramq28-Apr-09 2:03
Joramq28-Apr-09 2:03 
Questionhow can i send mail to all the members at a once...database contains the user details and email addresses........ Pin
jiya131127-Apr-09 21:10
jiya131127-Apr-09 21:10 
AnswerRe: how can i send mail to all the members at a once...database contains the user details and email addresses........ Pin
dotnetmember27-Apr-09 21:26
dotnetmember27-Apr-09 21:26 
QuestionImage to bitmap conversion error...again! Pin
sebogawa27-Apr-09 21:02
sebogawa27-Apr-09 21:02 
AnswerRe: Image to bitmap conversion error...again! Pin
stancrm27-Apr-09 21:24
stancrm27-Apr-09 21:24 
GeneralRe: Image to bitmap conversion error...again! Pin
Christian Graus27-Apr-09 22:08
protectorChristian Graus27-Apr-09 22:08 

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.