Click here to Skip to main content
14,659,351 members
Home » Discussions » C#
   

C#

 
AnswerRe: who makes the .tmp file which is displaed on IE. IS it IE or adobe Reader? Pin
Nagy Vilmos12-Jun-09 0:46
professionalNagy Vilmos12-Jun-09 0:46 
QuestionGetting null event in delegate Pin
salon11-Jun-09 18:35
Membersalon11-Jun-09 18:35 
AnswerRe: Getting null event in delegate Pin
PandemoniumPasha11-Jun-09 19:02
MemberPandemoniumPasha11-Jun-09 19:02 
AnswerRe: Getting null event in delegate Pin
Luc Pattyn11-Jun-09 19:03
sitebuilderLuc Pattyn11-Jun-09 19:03 
GeneralRe: Getting null event in delegate Pin
salon11-Jun-09 20:44
Membersalon11-Jun-09 20:44 
GeneralRe: Getting null event in delegate Pin
Mirko198011-Jun-09 21:30
MemberMirko198011-Jun-09 21:30 
AnswerRe: Getting null event in delegate Pin
Arjun Marwaha11-Jun-09 19:32
MemberArjun Marwaha11-Jun-09 19:32 
AnswerRe: Getting null event in delegate Pin
DaveyM6912-Jun-09 0:18
professionalDaveyM6912-Jun-09 0:18 
ButtonClicked will be null if there are no subscribers to the event (therefore the delegate's InvocationList is empty).

This example shows you how to do it. The ButtonClicked event here is initiated by the public PerformButtonClicked method being called on a class instance and in turn calling the OnButtonClicked method, but obviously in the real world the OnButtonClicked method would be called by the instance itself on response to a MouseDown or something.
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        TestClass test;
        public Form1()
        {
            InitializeComponent();
            test = new TestClass();
            test.ButtonClicked += new TestClass.ButtonClickedDelegate(test_ButtonClicked);
            test.PerformButtonClicked(@"C:\Windows");
        }

        void test_ButtonClicked(string path)
        {
            MessageBox.Show(path);
        }
    }

    public class TestClass
    {
        public delegate void ButtonClickedDelegate(string path);
        public event ButtonClickedDelegate ButtonClicked;

        protected virtual void OnButtonClicked(string path)
        {
            ButtonClickedDelegate handler = ButtonClicked;
            if (handler != null)
                handler(path);
        }

        public void PerformButtonClicked(string path)
        {
            OnButtonClicked(path);
        }
    }
}


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)

Question[Message Deleted] Pin
daffy_200311-Jun-09 14:31
Memberdaffy_200311-Jun-09 14:31 
AnswerRe: Can anyone help me? Pin
Christian Graus11-Jun-09 14:36
mveChristian Graus11-Jun-09 14:36 
GeneralRe: Can anyone help me? Pin
Not Active11-Jun-09 14:41
mentorNot Active11-Jun-09 14:41 
GeneralRe: Can anyone help me? Pin
Christian Graus11-Jun-09 14:44
mveChristian Graus11-Jun-09 14:44 
GeneralRe: Can anyone help me? Pin
Christian Graus11-Jun-09 15:06
mveChristian Graus11-Jun-09 15:06 
GeneralRe: Using of C# to do print,merge pdf Pin
daffy_200311-Jun-09 14:45
Memberdaffy_200311-Jun-09 14:45 
GeneralRe: Using of C# to do print,merge pdf Pin
Christian Graus11-Jun-09 14:48
mveChristian Graus11-Jun-09 14:48 
GeneralRe: Using of C# to do print,merge pdf Pin
daffy_200311-Jun-09 14:55
Memberdaffy_200311-Jun-09 14:55 
GeneralRe: Using of C# to do print,merge pdf Pin
Christian Graus11-Jun-09 14:56
mveChristian Graus11-Jun-09 14:56 
QuestionWhat do you think of this? Multithreaded remote registry handler Pin
jackgeek11-Jun-09 12:02
Memberjackgeek11-Jun-09 12:02 
AnswerRe: What do you think of this? Multithreaded remote registry handler Pin
jackgeek11-Jun-09 12:04
Memberjackgeek11-Jun-09 12:04 
AnswerRe: What do you think of this? Multithreaded remote registry handler Pin
harold aptroot11-Jun-09 12:09
Memberharold aptroot11-Jun-09 12:09 
Questioncannot insert into database 2005 using visual c# 2008 Pin
Adekolurejo11-Jun-09 11:33
MemberAdekolurejo11-Jun-09 11:33 
AnswerRe: cannot insert into database 2005 using visual c# 2008 Pin
Colin Angus Mackay11-Jun-09 12:24
MemberColin Angus Mackay11-Jun-09 12:24 
QuestionRe: cannot insert into database 2005 using visual c# 2008 Pin
Adekolurejo11-Jun-09 12:42
MemberAdekolurejo11-Jun-09 12:42 
AnswerRe: cannot insert into database 2005 using visual c# 2008 Pin
Colin Angus Mackay11-Jun-09 13:08
MemberColin Angus Mackay11-Jun-09 13:08 
GeneralRe: cannot insert into database 2005 using visual c# 2008 Pin
Adekolurejo11-Jun-09 13:20
MemberAdekolurejo11-Jun-09 13:20 

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.