Help with custom control and event.


D

David

I have a custom control that I'm working on. Everything was going swimmingly
until I needed its containing control to subscribe to an event. The problem
has to do with a separate event being raised unexpectedly. This is some code
in the control:

////////////////////////////////////////////////////////////////////////////////
public delegate void SelectionChangedHandler(object o, SelectionChangedArgs
e);

public class SelectionChangedArgs : EventArgs
{
private DefCharacter character;
public DefCharacter Character { get { return character; } }

public SelectionChangedArgs(ref DefCharacter character)
{
this.character = character;
}
}

public event SelectionChangedHandler SelectionChanged;

void RosterEditor_MouseDown(object sender, MouseEventArgs e)
{
// code omitted

// raise my SelectionChanged event
SelectionChanged(this, new SelectionChangedArgs(ref character));
}
////////////////////////////////////////////////////////////////////////////////

I have handlers for the SelectionChanged event in the parent and
parent-parent controls. The problem is that if I raise that event in
MouseDown, the MouseMove event is raised afterward, which leads to an
erroneous drag-and-drop. I have no idea why it gets raised, but only that it
doesn't happen if I comment the SelectionChanged line.

Do I just have to accept the fact that MouseMove will be raised and find
some way around it? Any advice would be appreciated. :)
 
Ad

Advertisements

D

David

Oh wow, disregard that. I was extremely confused and didn't know what I was
talking about.
 

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