Sign in to follow this  
Funkymunky

C# project forgetting assigned events?

Recommended Posts

I'm using MS Visual C# 2008 EE. I have a pretty complex project set up. Once in awhile when I load it up, it's forgotten a bunch of the events I assigned to different objects on the forms. Things like the MouseMove handler on a picturebox, or the Click event on a button. It's annoying to have to reassign the things after I frustratedly realize why my program isn't working anymore. Is this at least a known phenomenon, or is there something else going on here?

Share this post


Link to post
Share on other sites
I don't know; haven't experienced it myself.

If it's happening often enough you can wire up the events in your constructor as a workaround:


class MyForm
{
public MyForm()
{
InitializeComponent();

_pictureBox.MouseMove += HandlePictureMouseMove;
}

private void HandlePictureMouseMove(object sender, MouseEventArgs e)
{
}
}



This is the approach I take to avoid having to use the designer to wire up event handlers. It's easier for me to type the code.

Share this post


Link to post
Share on other sites
You don't edit the *.Designer.cs files manually do you? Those are generally considered non-programmer-editable and doing so can confuse the designer pretty easily.

Other than that, I've never really had this problem myself... you might want to invest in source code control software (Subversion, git, etc) which could help somewhat with trying to figure out why things have changed.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this