textbox的Multiline属性为true
在 textbox 中敲入回车跳转到下一个control,在OnKeysPress事件中写入了相应的代码
但是当敲入回车后,它是先在textbox中先回车了一下,再跳转,因此,在textbox.text后面其实多了一个回车,请问该如何将回车消除,或者屏蔽掉这个回车??
在 textbox 中敲入回车跳转到下一个control,在OnKeysPress事件中写入了相应的代码
但是当敲入回车后,它是先在textbox中先回车了一下,再跳转,因此,在textbox.text后面其实多了一个回车,请问该如何将回车消除,或者屏蔽掉这个回车??
<script>
function onTest()
{
if (event.keyCode == "13")
{
alert(document.all["test"].value);
}
}
</script>
<textarea id="test" onKeydown="onTest();"></textarea>
改成false.
static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers,
uint vk);[DllImport("user32.dll")]
static extern bool UnregisterHotKey(IntPtr hWnd, int id);private const int VK_RETURN = 0xD;private void Form1_Load(object sender, System.EventArgs e)
{
RegisterHotKey(textBox1.Handle, 1, 0, VK_RETURN);
}private void Form1_Closed(object sender, System.EventArgs e)
{
UnregisterHotKey(textBox1.Handle, 1);
}private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
if(richTextBox1.Text.Length != 0)
{
richTextBox1.Text += "\r\n";
}
richTextBox1.Text += textBox1.Text;
}
}that's ok.
if(e.KeyChar==(char)13)e.Handled=true