0

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:

label.MouseDown += new MouseEventHandler(lab_MouseDown);

label.MouseDoubleClick += new MouseEventHandler(lab_MouseDoubleClick);

private void lab_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.Text += "  double click";
        }
        
        private void lab_MouseDown(object s , MouseEventArgs e)
        {
            this.Text  += " mouse doen";
        }

is there any way i can manage these to events to work together ?

4
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Renukavani
0

the program is a game and i must use mouse down event. i cant use mouseclick.

0

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";
}
0

Assigning both to mouse down would not work as double click would always fire each time there was just a single mouse down

0

hi, i tested this coding. just try this

String str=String.Empty;
 private void label1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            str += "label1_MouseDoubleClick";
            label1.Text = str;
        }

        private void label1_MouseDown(object sender, MouseEventArgs e)
        {   str +="label1_MouseDown";
            label1.Text = str;
        }

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.