Click here to Skip to main content
15,897,273 members
Home / Discussions / C#
   

C#

 
AnswerRe: DataGrid .. DataSet .. Datatable [modified] Pin
nelsonpaixao23-Oct-08 14:42
nelsonpaixao23-Oct-08 14:42 
QuestionConnection to Exchange server Pin
boiDev23-Oct-08 11:13
boiDev23-Oct-08 11:13 
QuestionCustom Event Throwing Null When Called? Pin
Abydosgater23-Oct-08 7:31
Abydosgater23-Oct-08 7:31 
AnswerRe: Custom Event Throwing Null When Called? Pin
Gareth H23-Oct-08 7:41
Gareth H23-Oct-08 7:41 
GeneralRe: Custom Event Throwing Null When Called? Pin
Abydosgater23-Oct-08 7:52
Abydosgater23-Oct-08 7:52 
GeneralRe: Custom Event Throwing Null When Called? Pin
Gareth H23-Oct-08 8:03
Gareth H23-Oct-08 8:03 
GeneralRe: Custom Event Throwing Null When Called? Pin
Abydosgater23-Oct-08 8:05
Abydosgater23-Oct-08 8:05 
AnswerRe: Custom Event Throwing Null When Called? Pin
DaveyM6923-Oct-08 8:13
professionalDaveyM6923-Oct-08 8:13 
You've got something screwy going on somewhere in your code.

This is a simple sample that has 2 events - one with custom event args.
public class TestA
{
    public event EventHandler Property1Changed;
    public event EventHandler<TestEventArgs> Property2Changed;

    public int Property1
    {
        set { OnProperty1Changed(); }
    }
    public int Property2
    {
        set { OnProperty2Changed(value); }
    }
    protected virtual void OnProperty1Changed()
    {
        if(Property1Changed!=null)
            Property1Changed(this, EventArgs.Empty);
    }
    protected virtual void OnProperty2Changed(int value)
    {
        if (Property2Changed != null)
            Property2Changed(this, new TestEventArgs(value));
    }
}
public class TestEventArgs : EventArgs
{
    public TestEventArgs(int value)
    {
        m_Value = value;
    }
    private int m_Value;
    public int Value
    {
        get { return m_Value; }
    }
}

You can instanciate, subscribe to the events and set the properties to raise the events like:
TestA testA = new TestA();
testA.Property1Changed += new EventHandler(testA_Property1Changed);
testA.Property2Changed += new EventHandler<TestEventArgs>(testA_Property2Changed);
testA.Property1 = 1;
testA.Property2 = 2;

then the methods called above
void testA_Property2Changed(object sender, TestEventArgs e)
{
    Console.WriteLine("Property 2 Changed to: " + e.Value);
}

void testA_Property1Changed(object sender, EventArgs e)
{
    Console.WriteLine("Property 1 Changed.");
}


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)

AnswerRe: Custom Event Throwing Null When Called? Pin
Abydosgater23-Oct-08 8:34
Abydosgater23-Oct-08 8:34 
GeneralRe: Custom Event Throwing Null When Called? Pin
DaveyM6923-Oct-08 8:48
professionalDaveyM6923-Oct-08 8:48 
GeneralRe: Custom Event Throwing Null When Called? Pin
DaveyM6923-Oct-08 9:04
professionalDaveyM6923-Oct-08 9:04 
AnswerRe: Custom Event Throwing Null When Called? Pin
Giorgi Dalakishvili23-Oct-08 8:55
mentorGiorgi Dalakishvili23-Oct-08 8:55 
AnswerRe: Custom Event Throwing Null When Called? Pin
Abydosgater24-Oct-08 2:32
Abydosgater24-Oct-08 2:32 
QuestionPossible to hide mouse cursor in window that belongs to another program? Pin
vigylant23-Oct-08 5:35
vigylant23-Oct-08 5:35 
AnswerRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Michael Bookatz23-Oct-08 6:49
Michael Bookatz23-Oct-08 6:49 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
vigylant23-Oct-08 6:53
vigylant23-Oct-08 6:53 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Michael Bookatz23-Oct-08 6:58
Michael Bookatz23-Oct-08 6:58 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
vigylant23-Oct-08 7:02
vigylant23-Oct-08 7:02 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely23-Oct-08 7:02
Dan Neely23-Oct-08 7:02 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Michael Bookatz23-Oct-08 7:06
Michael Bookatz23-Oct-08 7:06 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Anthony Mushrow23-Oct-08 12:42
professionalAnthony Mushrow23-Oct-08 12:42 
AnswerRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 7:55
mveDave Kreskowiak23-Oct-08 7:55 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely23-Oct-08 8:24
Dan Neely23-Oct-08 8:24 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dave Kreskowiak23-Oct-08 9:11
mveDave Kreskowiak23-Oct-08 9:11 
GeneralRe: Possible to hide mouse cursor in window that belongs to another program? Pin
Dan Neely24-Oct-08 7:00
Dan Neely24-Oct-08 7:00 

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.