Visual C++ Programming
C++ (Non Visual C++ Issues)
Modern Windows Apps (Metro)
C++ and WinAPI
Managed C++ and C++/CLI
Visual C++ Bugs & Fixes
Graphics Programming
Network Programming
Driver Development
Visual Basic 6.0 Programming
Visual Basic .NET
Crystal Reports
C-Sharp Programming
Managed C++
Visual Basic .NET
.NET Framework
Windows Presentation Foundation (WPF) & XAML forum
.NET Installation and Configuration Issues
Java Programming
Scripting - Client Side
Wireless/Mobile Development
Scripting - Server Side (PHP, Perl, etc.)
General Developer Topics
Project Planning, Design, and Management
Testers and Testing
Algorithms & Data Structures
General Discussion / Chit Chat
Announcements, Press Releases, & News
Articles Suggestions
Testing Area
Programming Projects
C# Game(s) Project
Game Engine Project
C++ Coding Project
Project: Code War
Slow Chat: Talk with Microsoft Developer Teams
Slow Chat: Developing Multithreaded Applications
Slow Chat: C++0x
Slow Chat: Visual C++: Yesterday, Today, and Tomorrow
Directory Services
General Windows and DNA Programming
Windows OS Issues
Open Positions (Jobs)
Looking for Work
Visual Basic .NET FAQs
Visual Basic FAQs
CodeGuru Individual FAQs
CodeGuru Individual Visual Basic FAQs


Java Database
Software Development
Software Development


.NET Framework

Ask general questions about the .NET Framework. Discuss general CTS, CLR, and other .NET Platform questions and issues

Question about Events & delegates...

I'm quite new in .Net technologies and I have a question about the Events for Windows::Forms::Control    According to the .Net Framework developer Center,  the fellowing list are personalized Events  for Control :    AutoSizeChanged   BackColorChanged  BackgroundImageChanged  BackgroundImageLayoutChanged  Click  .....  ....    Am'I right If I say that they are methods pointers and a Control have many methods pointers than events?    thanks,  Michel.  				  			

  				  					Delegates are in general Functions/Methods pointers.    A control raises many events (like the ones on your list).    When you implement an event handler for a defined control event you need to link that event handler (which is a function) to the event through a delegate  like this:      	Code:  	button.Click += new EventHandler(this.Button_Clicked);   When button is the name of the control, Click is the event and Button_Clicked is the name of your method.   EventHandler is a generic delegate (System.EventHandler).    This code is written automatically in C# when you for example double click on a button on a designer.   In VB you got a syntax like Handles.button.Click right after the declaration line (the first line) of your function.  				  			

  				  					Thanks you for your reply,  but the thing I want to know "Type" is event Click?  What is an "event Click"?    because we can do semothing like this :    button.Click += new EventHandler(this.Button_Clicked);    I guest that Click is a kind of array of functions/methods pointers.      Perharps I'm not clear...  I'm not a natif english speaker     Michel.  				  			

  				  					Event is not a type, is just a keyword.    quoting from MSDN:    "The event keyword lets you specify a delegate that will be called upon the occurrence of some "event" in your code. The delegate can have one or more associated methods that will be called when your code indicates that the event has occurred. "    You can specify your own events, but in order to specify events and handle them you should:      	Code:  	//1) declare a delegate:  public delegate void myEventHandler(object sender, AlarmEventArgs e);    //2) "declare" an event on your delegate   //(read the first sentence from the quote now):  public event myEventHandler myEvent;    //3)Wire event and SomeMethod through the event delegate   //(At some initialization stage)  myControl.myEvent += new myEventHandler(SomeMethod);   You can do this without explictly declaring a delegate and event if you are using .NET built in controls, because they already have their own events and delegates (EventHandler - which uses a generic System.EventHandler delegate) declared, as shown in the previous post, so you can just wire an event to SomeMethod using the generic delegate called EventHandler.    Sorry it is not clear enough, but if you go through some tutorials you'll start catching these sometimes confusing concepts.     Hope it might Help!     JI

Related Links

Custom Checkbox List
"Overtaking" a setup install with J#
Q: POOM and named properties
debugging a child process
Add sizegrip to form
Using of ComboBox
Using .Net Version 1.x and Version 2.0 with Visual Studio 2003
hide taskbar
TextBox problem !!!
compress files into a dll
Problem with ComboBox
ComboBox Methods in VC++.Net
Use of String::Format Method