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 / April 2005

Tip: Looking for answers? Try searching our database.

sender in MouseEvents

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
simonrigby_uk@hotmail.com - 14 Apr 2005 17:18 GMT
Hi folks,

Small issue with sender argument in mouse events.

I have a container control that users can add instances to of a another
control at runtime. In response to the user adding a new control (Task)
to the container (Pad), I create a new instance of Task, add two
handlers, one for MouseUp and one for MouseDown and then add the Task
to Pad.Controls.

I then want the user to be able to link them by dragging from one to
the other, so the user MousesDown on one instance and MousesUp one
another.

If i quiz the sender argument in the MouseDown delegate and the MouseUp
delegate it seems that sender is always the instance that raised the
MouseDown. I have quizzed the hascodes of the sender as well as
declaring a private member of the Task when its created that just
records the time it was created.

Both instances of the Task control are unique (different hashcodes,
different private variable values, instanceA.Equals(instanceB) ==
False).

Its like the sender remembers the instance that raised the MouseDown.

Any help greatly appreciated.

Bonnie, if you read this, your help got me through making sure they
were unique instances but still the same problem.

Cheers

Simon Rigby
Diggers - 14 Apr 2005 22:22 GMT
Extra thoughts to see if this helps anyone. Is it possible that the
first control clicked is getting the focus, then despite the fact that
cursor leaves that control and rests over another, for all intents and
purposes the first control still has the mouse focussed on it.

Cheers (this driving me nuts)!!!

Simon
Bonnie Berent [C# MVP] - 19 Apr 2005 17:43 GMT
Simon,

I think you want to use the Drag/Drop event stuff rather than the MouseDown,
MouseUp stuff. See if that helps ...

~~Bonnie

> Hi folks,
>
[quoted text clipped - 30 lines]
>
> Simon Rigby
Diggers - 22 Apr 2005 03:54 GMT
Hi Bonnie,

Thanks again. I had tried this before but made the mistake of
initiating the DragDrop in the client object. When I handled it in the
container, it worked perfectly.

Cheers

Simon
Bonnie Berent [C# MVP] - 22 Apr 2005 15:39 GMT
Cool, Simon ... glad you got it working. =)

~~Bonnie

> Hi Bonnie,
>
[quoted text clipped - 5 lines]
>
> Simon

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.