VB to C# Translation

G

Guest

What is the equivalent of the "Handles Me.Init" code in C#?

Private Sub StockDog_Init(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Init

Fetch(StockTicker)

End Sub

Thanks in advance for your assistance!!!
 
N

Nicholas Paldino [.NET/C# MVP]

Jim,

This is the way that VB assigns event handlers. In C#, on construction
of the object, you would do something like:

this.Init += StockDog_Init;
 
N

Nicholas Paldino [.NET/C# MVP]

Jim,

I would have the designer do it. Go to the Init event in the properties
grid (check the thunderbolt to get a list of events) then double click on
the Init event, and it should wire everything up for you.
 
E

Eric Renken

Actually once you do:

this.Init +=

And hit tab twice it should create the proper code after the =. The code
should look more like:

this.Init += new System.EventHandler(EventHandler);

Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top