Click here to Skip to main content
15,918,668 members
Home / Discussions / C#
   

C#

 
AnswerRe: About dateTimePicker problem Pin
avigodse26-Nov-09 18:56
professionalavigodse26-Nov-09 18:56 
AnswerRe: About dateTimePicker problem Pin
Shameel26-Nov-09 20:05
professionalShameel26-Nov-09 20:05 
AnswerRe: About dateTimePicker problem Pin
ScottM126-Nov-09 22:13
ScottM126-Nov-09 22:13 
GeneralRe: About dateTimePicker problem Pin
PIEBALDconsult27-Nov-09 2:59
mvePIEBALDconsult27-Nov-09 2:59 
QuestionRe: About dateTimePicker problem Pin
ScottM127-Nov-09 3:04
ScottM127-Nov-09 3:04 
AnswerRe: About dateTimePicker problem Pin
PIEBALDconsult27-Nov-09 4:45
mvePIEBALDconsult27-Nov-09 4:45 
QuestionDelegates and Events Pin
BobInNJ26-Nov-09 12:51
BobInNJ26-Nov-09 12:51 
AnswerRe: Delegates and Events Pin
Luc Pattyn26-Nov-09 13:08
sitebuilderLuc Pattyn26-Nov-09 13:08 
Hi Bob,

When your Main (or any other code) wants to do something to stock1, it should set one of its properties, or call one of its methods.

events are meant to be used the other way around; they exist for the external world (Main) to be signaled by something that happens inside your class (Stock), as in:

class MyForm : Form {
    public MyForm() {
        Button btn=new Button();
        this.Controls.Add(btn);
        btn.Click+=new EventHandler(myClickHandler);
...
        public void myClickHandler(object sender, EventArgs e) {
            // whatever this form wants to happen when the button detects it is being clicked
        }
    }


and the Button class would contain something like:
if (a click got detected) {
    if (this.Click!=null) this.Click(this, new EventArgs()); // execute all the delegates that were
              // added to the Click event
}


so it is Button who executes its own event, and MyForm who subscribed to it by adding its myClickHandler to the public event.

And all this holds true for .NET, not just for C#.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages


AnswerRe: Delegates and Events Pin
Yuri Vital26-Nov-09 13:16
Yuri Vital26-Nov-09 13:16 
AnswerRe: Delegates and Events Pin
PIEBALDconsult26-Nov-09 15:11
mvePIEBALDconsult26-Nov-09 15:11 
AnswerRe: Delegates and Events Pin
N a v a n e e t h26-Nov-09 16:42
N a v a n e e t h26-Nov-09 16:42 
GeneralRe: Delegates and Events Pin
Yuri Vital26-Nov-09 20:59
Yuri Vital26-Nov-09 20:59 
GeneralRe: Delegates and Events Pin
N a v a n e e t h27-Nov-09 0:22
N a v a n e e t h27-Nov-09 0:22 
Questionanother web browser control?!! Pin
Jassim Rahma26-Nov-09 11:56
Jassim Rahma26-Nov-09 11:56 
AnswerRe: another web browser control?!! Pin
Abhishek Sur26-Nov-09 12:01
professionalAbhishek Sur26-Nov-09 12:01 
GeneralRe: another web browser control?!! Pin
Jassim Rahma26-Nov-09 12:08
Jassim Rahma26-Nov-09 12:08 
AnswerRe: another web browser control?!! Pin
ScottM126-Nov-09 22:14
ScottM126-Nov-09 22:14 
QuestionWindows Forms Context Menu Spacer Pin
Jammer26-Nov-09 9:43
Jammer26-Nov-09 9:43 
AnswerRe: Windows Forms Context Menu Spacer Pin
DaveyM6926-Nov-09 9:48
professionalDaveyM6926-Nov-09 9:48 
GeneralRe: Windows Forms Context Menu Spacer Pin
Jammer26-Nov-09 10:34
Jammer26-Nov-09 10:34 
GeneralRe: Windows Forms Context Menu Spacer Pin
DaveyM6926-Nov-09 10:48
professionalDaveyM6926-Nov-09 10:48 
GeneralRe: Windows Forms Context Menu Spacer Pin
Jammer26-Nov-09 10:50
Jammer26-Nov-09 10:50 
QuestionMultithreading C# Pin
J imran26-Nov-09 6:09
J imran26-Nov-09 6:09 
AnswerRe: Multithreading C# Pin
Ravi Bhavnani26-Nov-09 6:28
professionalRavi Bhavnani26-Nov-09 6:28 
AnswerRe: Multithreading C# Pin
Abhijit Jana26-Nov-09 6:54
professionalAbhijit Jana26-Nov-09 6:54 

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.