[問題] 送出textbox內容
大家好
最近在寫一個windows form小程式
希望 點擊button或者按下enter都可以送出textbox內容的
button基本上沒有問題
鍵盤判斷enter我使用KeyPress事件來判斷
但是只有第一次送出的textbox內容是正確的
其他只要有按下enter這個動作
就會產生 跳行+textbox內容
嘗試過兩個方法
1.清掉textbox內容
2.把textbox內容丟進Str[]裡面 然後從Str[1]開始輸出
不過跳行的問題仍然存在
以下是KeyPress事件的code 希望各位能給點意見 謝謝:)
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) {
String userinput = this.textBox1.Text;
if (e.KeyChar == 13)
{
if (userinput == "1")
{
MessageBox.Show("userinput:" + userinput, "message box");
this.textBox1.Text = null;
CallAdd();
CallMrec();
}
else
{
MessageBox.Show("userinput:" + userinput, "message box");
this.textBox1.Text = null;
}
}
}
--
Rock N' Roll Ain't Noise Pollution
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.221.67.235
→
01/13 15:07, , 1F
01/13 15:07, 1F
→
01/13 15:08, , 2F
01/13 15:08, 2F
推
01/14 03:55, , 3F
01/14 03:55, 3F
→
01/14 09:36, , 4F
01/14 09:36, 4F
討論串 (同標題文章)