.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 12th, 2003, 09:15 AM
SirX SirX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 64 SirX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 30 sec
Reputation Power: 10
Create onClick event

I created an own component which contains a button. How can I create an onClick event for this button? This onClick should be visible in the property-window!

I found this code but I do not know what to do next?

Code:
__property CodeEventReferenceExpression* get_Event();

__property void set_Event(CodeEventReferenceExpression*);

Reply With Quote
  #2  
Old September 16th, 2003, 02:09 PM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 11
Assuming you're coding a Windows Application (not a ASP.Net Web UserControl)...

Just define a public event and a custom delegate (if you want to)...that's it :-)

Code:
public class UserControl1 : System.Windows.Forms.UserControl {
  
  // ...
  
  public event EventHandler OnClick;
  
  // ...
  
  public void SomeFuncWhichFiresClickEvent() {  
    // ...
    
    // fire event
    if (OnClick != null)
      OnClick(this, new EventArgs());    
  }
  
  // ...
 
}

Reply With Quote
  #3  
Old September 17th, 2003, 08:42 AM
SirX SirX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 64 SirX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 30 sec
Reputation Power: 10
I tried your example but got those errors:

c2146: missing ';' before identifier 'EventHandler'
c2501: 'GStatusBar::GStatusBarControl::event' : missing storage-class or type specifiers

What´s wrong?

Reply With Quote
  #4  
Old September 17th, 2003, 11:51 AM
Wingman Wingman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Bavaria, Germany
Posts: 140 Wingman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 40 m 41 sec
Reputation Power: 11
Hmm, your error message looks like you're coding in C++? Perhaps some of the moderators should append to the "READ: How To Post" a short message that new posts in this specific board should add Language (c++, c# or VB) and what section, so its easier to track down what is ment (since the topic of this board is very wide-ranged...)

Try this one:

Code:
__gc class YourClass {

public:
   __event ClickEventHandler* OnClick;  // declare the event 

   void FireEvents() {
      OnClick(0, 1);
   }

};


The code you saw is what the compiler generates out of the above statements, see http://msdn.microsoft.com/library/d...ionsSpec_10.asp.

That should do the trick

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Create onClick event

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap