Tech Support > Microsoft Windows > Development Resources > How do I add components in Visual Studio Express C#?
How do I add components in Visual Studio Express C#?
Posted by James Davis on April 14th, 2008


I am studying for an MCSD exam so learning to program in C#. Here's
the problem. The book I have wants me to add a component (separate
from the main form) and then put a timer on that component. I was
able to do that in my 60 day evaluation version Microsoft Visual
Studio .NET 2003, but this version has somehow crashed after I
installed some Server 2003 updates and I have thrown away the CD.

So I installed the free Visual Studio Express C#, but this doesn't
offer the choice to add a component. You are probably saying I should
just add a class. But here is the problem. I can't get the timer to
be in the same scope as the class it is supposed to act on, because I
can only drop the timer on the main Form instead of creating a
component for my DoghnutMachien class and dropping the timer in
there.

I created a class called DoughnutMachine in the main form, since I
can't make a separate component for it. But I can't put the timer
inside the class to create doughnuts at intervals. This is because
the class is just a class, not an instance of a class, and the timer
is tied to the main form. Now, I could create an instance of
DoughnutMachine, but then I would have to put the controlling code
that makes decisions and uses the timer OUTSIDE of the Doughnut
Machine class to use the timer. I would have to pass the particular
instance of the DoughnutMachine each time back and forth. this isn't
what I want. I want the timer INSIDE the DoughnutMachine class.

The natural way to do that is to add a component for the
DoughnutMachine class, and drop a timer on it. But the Add Component
menu item is not on the Project menu in Visual C#. Any way to do it?


Similar Posts