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 ?

Try assigning it to "MouseClick" not mousedown..

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

Well at the same time down and double click work for me.

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.