Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2007

Tip: Looking for answers? Try searching our database.

Help with custom control and event.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 24 Oct 2007 02:46 GMT
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. :)
David - 25 Oct 2007 15:40 GMT
Oh wow, disregard that. I was extremely confused and didn't know what I was
talking about.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.