Philip Borchert

I am working inside Visual Studio 2005 and am having a terrible time with the designer and a custom event. What happens is when I double click on my custom event inside the property window the designer opens the code window and does everything it normally does when working with an event. I save all my wok close the form, and reopen return to look at my custom event it appears that it is no longer assigned However, clicking in the event window and using the drop down combo box I can reassign the event to my coded event. However saving again and closing and reopening the form once again reproduces the same results

I have no problems posting my code I would prefer to actually email a zipped copy of my code to anyone interested in seeing it for themselves. I've made a silly program to work with this bug, so it's pretty small it's just a car with a little fuel gauge above it that runs across a windows form and runs out of gas (raising the event). The program works fine, it's just strictly a designer issue.

Version Info:

Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727



Re: Visual C++ General Designer Custom Event with a Delegate Disappears from property window

Philip Borchert

Ok, so maybe posting some code will help And steps to reproduce this what I feel will turn out to be a bug.

1. Create a c++ windows forms project (call it testform if you will)

2. Create a c++ user control project (call it car if you will)

3. Create a c++ class that derives from System::EventArgs and assign it some quick properties or so.

Code Block

#pragma once

using namespace System;

using namespace System::ComponentModel;

using namespace System::Windows::Forms;

namespace Car

{

public ref class FuelEmptyEventArgs : System::EventArgs

{

public:

//constructor

FuelEmptyEventArgs(void)

{

locationX = 0;

locationY = 0;

};

FuelEmptyEventArgs(int X, int Y)

{

locationX = X;

locationY = Y;

};

property int LocationX

{

int get(void)

{

return locationX;

};

}

property int LocationY

{

int get(void)

{

return locationY;

};

}

private:

int locationX;

int locationY;

};

}//namespace

4. Inside your control create a delegate, and an event.

Code Block

public:

delegate void FuelEmptyHandler(System::Object ^sender, FuelEmptyEventArgs ^e);

event FuelEmptyHandler ^FuelEmpty

{

void add(FuelEmptyHandler ^value)

{

PrivateFuelEmpty += value;

}

void remove(FuelEmptyHandler ^value)

{

PrivateFuelEmpty -= value;

}

}

private:

FuelEmptyHandler ^PrivateFuelEmpty;

5. Build and add the control to the tool box or if your ide is setup like mine it will add it for you.

6. Open your testform and drop your user control onto the form.

7. Select your user controls properties and then the event tab

8. Double click on your custom event (In my example it is FuelEmpty) and should be under misc.

9. Add a message box or something to the event it creates.

10. Close the form

11. Open the form back up and check if your event is still present... (notice it is not)

12. Move your control or change something to cause the designer to resave the code. Now your event is completely unassigned

I hope this encourges some sort of better response





Re: Visual C++ General Designer Custom Event with a Delegate Disappears from property window

Philip Borchert

Well, it appears that almost 90 some other people have looked at this thread. I've been working with microsoft on the issue, and while it has been reproduced and verified as a bug, the workaround of placing the mapping inside the form_load event to ensure it does not get lost between opening and closing the designer for the form seems to be the best answer at this point. Which I guess is much better then writing a custom serializer like I was looking into doing to attempt to remedy the situation myself.





Re: Visual C++ General Designer Custom Event with a Delegate Disappears from property window

Philip Borchert

If your still reading at this point I congradulate you.
In further research of the issue we have found a similarity to KB 943455 ( http://support.microsoft.com/kb/943455 ) last reviewed Oct 6 of this year. However this just goes to further point out the fact that the C++ Form serialization and deserialization need to be fixed. I am still working with Microsoft on this issue and hope to have more details in the near future.
Also if this issue is of importance to you and you'd like to help me in my efforts please voice your opinons at my feedback to the visual studio team at https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx FeedbackID=307922