private void PositionCursor(object sender, PaintEventArgs e)
{
Font arialBold = new Font("Arial", 14.0F);
if (trigger)
{
TextRenderer.DrawText(e.Graphics, ("X"), arialBold,
new Point(x * 20 - 4, y * 20 - 2), Color.Red);
trigger = false;
}
}
private void MoveCursor(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Up:
y--;
break;
case Keys.Left:
x--;
break;
case Keys.Down:
x++;
break;
case Keys.Right:
y++;
break;
}
trigger = true;
}
Hello,
I'm trying to navigate a “X” on a winforms application by its x and y coordinates. I also tried the MoveCursor method with a ProcessCmdKey method instead of the KeyEventArgs. In both cases the switch operation does work fine, If I display the x and y values by a MessageBox the values change properly. But I don’t get the PaintEvent triggered when a Key is pressed, and I can’t find my thinking error. Please help me. Thanks!