Visual C 2005 Removing Event Handlers When Designer Reloading

  • Thread starter Thread starter gnassar
  • Start date Start date
G

gnassar

Essentially my problem is that .NET 2005 is removing my event
handlers. There's no real special things about my project, it just
continually removes them all.

It starts on the open of a solution. The screen flashes and
immediately I can undo something. I look at the undo list and it says
designer generated code. When I undo it, all of my event handlers come
back. This is a very annoying issue has anyone solved this problem?

-G
 
Essentially my problem is that .NET 2005 is removing my event
handlers. There's no real special things about my project, it just
continually removes them all.

It starts on the open of a solution. The screen flashes and
immediately I can undo something. I look at the undo list and it says
designer generated code. When I undo it, all of my event handlers come
back. This is a very annoying issue has anyone solved this problem?

Perhaps put the wire-up code in the constructor, not in InitializeComponent
that the designer messes with.
 
That doesn't make sense.

I'm not placing code in myself to begin with. When I add a windows
form component, and then choose the events button in the GUI, then
double click say: OnLoad the gui creates a function for me at the end
of the document called OnLoad. On top of that it places a handler in
the generated code itself in the designer generated code mapping this
control to the handler. What you're asking, or suggesting is that I
not only insert handlers using the GUI but then go back and place them
outside of the generated code.

I think that you may have misunderstood me. I'm not editing that area.
I'm not touching it. Anything that should be there should be placed by
the IDE itself. The problem is that the IDE is removing my handlers
itself after I reopen a project.

Note that it does not delete the functions it just removes the maps to
them.

Gus
 
That doesn't make sense.

I'm not placing code in myself to begin with. When I add a windows
form component, and then choose the events button in the GUI, then
double click say: OnLoad the gui creates a function for me at the end
of the document called OnLoad. On top of that it places a handler in
the generated code itself in the designer generated code mapping this
control to the handler. What you're asking, or suggesting is that I
not only insert handlers using the GUI but then go back and place them
outside of the generated code.

I think that you may have misunderstood me. I'm not editing that area.
I'm not touching it. Anything that should be there should be placed by
the IDE itself. The problem is that the IDE is removing my handlers
itself after I reopen a project.

I thought you asked for a simple workaround, so I offered one. Go again and
file bug reports, but designer support for C++/CLI will quite possibly go
away entirely (it's far more complicated to support than any other
language). C++/CLI is positioned as a gateway, from .NET to any non-.NET
system, it does this well and most MVPs are encouraging MS to focus efforts
on C++ with CLR toward making that even better. Since it's so easy to mix
C# and C++ code, and any C++ programmer can immediately use C# quite well,
the brunt of design-time GUI support is always going to be focused on C# and
VB.NET

The only advantages C++ has over C# for GUIs, are things like template
metaprogramming, which are far too sophisticated to hope the designer would
ever help with.
 
I thought you asked for a simple workaround, so I offered one. Go again and
file bug reports, but designer support for C++/CLI will quite possibly go
away entirely (it's far more complicated to support than any other
language). C++/CLI is positioned as a gateway, from .NET to any non-.NET
system, it does this well and most MVPs are encouraging MS to focus efforts
on C++ with CLR toward making that even better. Since it's so easy to mix
C# and C++ code, and any C++ programmer can immediately use C# quite well,
the brunt of design-time GUI support is always going to be focused on C# and
VB.NET

The only advantages C++ has over C# for GUIs, are things like template
metaprogramming, which are far too sophisticated to hope the designer would
ever help with.

My apologies if I seemed rash. Thanks for the workaround, I just am
annoyed that I may have to do this for every future project I have to
do.

Gus
 
My apologies if I seemed rash. Thanks for the workaround, I just am
annoyed that I may have to do this for every future project I have to
do.

If I might suggest -- if you want good designers, use C# for the GUI and add
your C++/CLI projects as assembly references.

Can you check whether Orcas also exhibits this problem? It's unlikely that
any C++/CLI designer improvements will be made post Orcas.
 
Back
Top