ray dona

ray dona

  • NA
  • 29
  • 0

disable mouse cursor

Feb 16 2009 12:18 PM

Hi,

I have two text boxes, say textBox1 and textBox2. For the key press event of the first text box I have:

private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)

{ if(!(Char.IsLetter(e.KeyChar)) && e.KeyChar != 8)

{ e.Handled = true;

if(e.KeyChar == 13)

{ //do something

}

}

}

The trouble is that if the user, after entering something into the first text box, uses the mouse rather than the carriage return button to switch focus to the second text box the code to be executed after if(e.KeyChar == 13) is bypassed. How can I prevent the user from switching focus using the mouse, he must press the carriage return button after entering characters to switch focus.


Answers (1)