|
-
Apr 30th, 2004, 08:27 PM
#1
Thread Starter
Fanatic Member
withevents
Hi,
i am translating some code from vb.net to c# and am having trouble with the 'withevents' declaration of a variable. For example how do i declare this in c#
Code:
Dim WithEvents myObj as Outlook.Application
'the event is then
Public sub MailSend(byval item as object, byref cancel as boolean) handles myObj.Itemsend
End sub
many thanks if you can help
nick
-
Apr 30th, 2004, 10:28 PM
#2
PowerPoster
Outlook.Application myObj = new Outlook.Application();
Somewhere in a method (load, constructor, etc), place something like this..(exact code might be a little off, but the idea is the same) You have to subscribe to the event:
public MyConstructor
{
myObj.ItemSend += new ItemSend(MailSend);
}
public void MailSend(object item, boolean cancel)
{
//Code here.
}
-
May 1st, 2004, 05:27 AM
#3
Thread Starter
Fanatic Member
thanks. moving from vb.net to c# is a little more tricky than i expected!
Cheers
Nick
-
May 1st, 2004, 12:13 PM
#4
PowerPoster
Remember, the VS.NET IDE will help you out with these if you start typing it, you will notice little tooltip windows. They start saying press tab to fill in, then press tab again to create the stub. So, when you create them, it is pretty easy.
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
|