|
-
May 21st, 2004, 01:58 AM
#1
a question about events
I have this code
PHP Code:
internal event EBLinkClickedHandler onLinkClicked
{
add
{
this.myLinkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler (linkLabel_LinkClicked);
}
remove
{
this.myLinkLabel.LinkClicked -= new LinkLabelLinkClickedEventHandler (linkLabel_LinkClicked);
}
}
it's basially an event property, or whatever it's called. The problem is that it won't let me fire the event by calling onLinkClicked()... is there any way to declare my event the way I just did above and still be able to fire it? when I try onLinkClicked() I get this error The event 'ControlsEx.ExplorerBarControl.EBLinkItem.onLinkClicked' can only appear on the left hand side of += or -=
I can fire it if I dont declare the event as a property, but I kinda want to declare it that way
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 21st, 2004, 01:24 PM
#2
nevermind I'm dumb
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 26th, 2004, 07:59 AM
#3
yay gay
Hmm? What are taht "add" and "remove" things inside of the event? I didn't know about it! Tell me what do they do and how do they work
\m/  \m/
-
May 26th, 2004, 01:41 PM
#4
hehe I dont quite know myself... I dont really "know" C#, I just opened up VS one day and started messing in C# and that's how I work
in some situations I figure out that doing the events that way works a lot better for me. Add is when the user adds the event handler, and remove is called when you're removing it I guess
I guess this could be one case where it can make it easier for you. But I dont really know what the real purpose of it is... maybe someone with a better C# knowledge can correct me if I'm wrong. But take a look at this example... may make more sense:
PHP Code:
private void Form1_Load(object sender, System.EventArgs e)
{
this.WindowsDied += new EventHandler(Form1_WindowsDied);
}
private void Form1_WindowsDied (object sender, EventArgs e)
{
MessageBox.Show ("Your windows has passed away. Thank you");
}
public event EventHandler WindowsDied
{
add
{
this.Click += value;
this.Closed += value;
this.button1.Click += value;
}
remove
{
this.Click -= value;
this.Closed -= value;
this.button1.Click -= value;
}
}
now if you click on button1, or the form, or if you close the form you get that message...
btw does anyone know what exacly the purpose of the "event" keyword is? because it works without it also
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 26th, 2004, 01:44 PM
#5
umm and regarding the first post, if you really want to be able to raise the event manually you gotto declare another variable:
PHP Code:
private EventHandler windowsDied;
public event EventHandler WindowsDied
{
add
{
this.Click += value;
this.Closed += value;
this.button1.Click += value;
this.WindowsDied += value;
}
remove
{
this.Click -= value;
this.Closed -= value;
this.button1.Click -= value;
this.WindowsDied -= value;
}
}
seems like stupid, I dont know if anyone does this
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
May 26th, 2004, 05:53 PM
#6
Sleep mode
That's weird . Add and Remove aren't keywords in C# , I believe . Some gurus use like these secrets by they don't explain what they're doing ...
-
May 26th, 2004, 06:50 PM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|