Texto debajo del cursor del mouse en PictureBox

I have a problem with displaying the text under the mouse cursor on Picture Box. I want to dynamically display the mouse coordinates under the cursor.

I'm trying to display text by label and change the label's position when a "MouseMove" event happens.

 private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        label1.Location = new Point(e.X + 10, e.Y + 10);

But, I think, it is a bad solution... And although it works it hides other output when we move the cursor

¡Muchas gracias!

preguntado el 10 de marzo de 12 a las 10:03

why do you think it's a bad solution? I personally would do the same :) -

I think that using MouseMove is a bad 'move'. You get many events in rapid sequence and moving an object as simple as a label is very time consuming -

Maybe you can use a ToolTip? I'm not sure if it offers all the methods you'll need, but it might be worth giving it a try. -

Yes I agree with thomas...its much better from performance point of view that instead of anyother event, you can use tooltip which is light weighted work around...!! -

1 Respuestas

Thanks for Thomas's advice, here code to display mouse coordinate under cursor:

ToolTip tt = new ToolTip();
tt.SetToolTip(pic, " ");
tt.ShowAlways = true;

 private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    tt.ToolTipTitle = e.X + "  " + e.Y; 

respondido 10 mar '12, 13:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.