RSS Forums RSS
Please support our C# advertiser: Programming Forums
Views: 576 | Replies: 6
Reply
Join Date: Nov 2007
Posts: 89
Reputation: emilio is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
emilio emilio is offline Offline
Junior Poster in Training

label double click

  #1  
Sep 28th, 2008
i have a problem with a simple program.

my program has a label.
i tryed to add event handlers for both mouse down event
and mouse double click event.

it seems that when these two handlers are defined, only the mouse down event is responding.
the double click event simply does not respond. but when i disable the mouse down event, it works fine

my code is:

  1. label.MouseDown += new MouseEventHandler(lab_MouseDown);
  2.  
  3. label.MouseDoubleClick += new MouseEventHandler(lab_MouseDoubleClick);
  4.  
  5. private void lab_MouseDoubleClick(object sender, MouseEventArgs e)
  6. {
  7. this.Text += " double click";
  8. }
  9.  
  10. private void lab_MouseDown(object s , MouseEventArgs e)
  11. {
  12. this.Text += " mouse doen";
  13. }

is there any way i can manage these to events to work together ?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2008
Posts: 997
Reputation: LizR will become famous soon enough LizR will become famous soon enough 
Rep Power: 3
Solved Threads: 93
LizR LizR is online now Online
Posting Shark

Re: label double click

  #2  
Sep 28th, 2008
Try assigning it to "MouseClick" not mousedown..
Reply With Quote  
Join Date: Nov 2007
Posts: 89
Reputation: emilio is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
emilio emilio is offline Offline
Junior Poster in Training

Re: label double click

  #3  
Sep 28th, 2008
the program is a game and i must use mouse down event. i cant use mouseclick.
Reply With Quote  
Join Date: Aug 2008
Posts: 997
Reputation: LizR will become famous soon enough LizR will become famous soon enough 
Rep Power: 3
Solved Threads: 93
LizR LizR is online now Online
Posting Shark

Re: label double click

  #4  
Sep 28th, 2008
Well at the same time down and double click work for me.
Reply With Quote  
Join Date: Jul 2007
Location: Philippines
Posts: 255
Reputation: jireh is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 28
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz in Training

Re: label double click

  #5  
Sep 29th, 2008
I don't know if this is correct but try this out hope it would help...

this.label1.MouseDown += new MouseEventHandler(this.label1_MouseDown);
this.label1.MouseDown += new MouseEventHandler(this.label1_DoubleClick);

private void label1_DoubleClick(object sender, MouseEventArgs e)
{
    this.label1.Text += " double_click";
}

private void label1_MouseDown(object sender, MouseEventArgs e)
{
    this.label1.Text += " mouse_Down";
}
Reply With Quote  
Join Date: Aug 2008
Posts: 997
Reputation: LizR will become famous soon enough LizR will become famous soon enough 
Rep Power: 3
Solved Threads: 93
LizR LizR is online now Online
Posting Shark

Re: label double click

  #6  
Sep 29th, 2008
Assigning both to mouse down would not work as double click would always fire each time there was just a single mouse down
Reply With Quote  
Join Date: Jul 2008
Posts: 55
Reputation: Renukavani is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
Renukavani Renukavani is offline Offline
Junior Poster in Training

Re: label double click

  #7  
Oct 2nd, 2008
hi, i tested this coding. just try this
  1. String str=String.Empty;
  2. private void label1_MouseDoubleClick(object sender, MouseEventArgs e)
  3. {
  4. str += "label1_MouseDoubleClick";
  5. label1.Text = str;
  6. }
  7.  
  8. private void label1_MouseDown(object sender, MouseEventArgs e)
  9. { str +="label1_MouseDown";
  10. label1.Text = str;
  11. }

and how many times u r pressing mousedown that many times label1_mousedown wil show and in label1 property just change Autosize=false;

if u have any problem stil let me know

if its working fine dont forget to mark problem solved
Last edited by Tekmaven : Oct 2nd, 2008 at 12:14 pm. Reason: Code tags
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:49 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC