how to do this:
when i'll press开发者_C百科 'G'
on textbox in my form i'll see 'A'
?
in C# code (windows-CE or Windows-mobile)
thank's in advance
TextBox t = new TextBox();
t.KeyPress += new KeyPressEventHandler(t_KeyPress);
void t_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 'G')
e.KeyChar = 'A';
}
I think you should handle the KeyPress event. Check if the key pressed is G, if yes, reject the input and put A in the textbox. Try this (The character will be appended to existing text:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar == 'G')
{
// Stop the character from being entered into the control
e.Handled = true;
textBox1.Text += 'A';
}
}
精彩评论