0

ユーザーが TextBox にフォーカスを置いて文字を入力すると、その文字が TextBox にまったく表示されたくないので、使用したくない TextBox に他のテキストがある可能性があるため、Clear() メソッドを使用したくありません。消したくありません。これまで私は試しました:

private void WriteBox1_KeyPress(object sender, KeyPressEventArgs e)
{      
            if (e.KeyChar == (char)13) // enter key pressed 
            {
                WriteBox1.Text = "";
            }

             // Code to write Serial....

            String writeValues = WriteBox1.Text;
            String withoutLast = writeValues.Substring(0, 1);

            WriteBox1.Text = withoutLast;

}

これにより、最後に入力された文字が writeBox1 に残ります。入力したすべての文字を削除する必要があります。私も疲れました:

writeValues.Replace(writeValues, "");
WriteBox1.Text = writeValues;
4

1 に答える 1