I have a textbox which has keydown event when entered key is “return” I have a barcode reader who read text into it but it is not writing more than one key i.e. only one letter is written lets say “a” and if i write second letter “a” is overwritten to become “b” but does not become “ab”. Does anyone know what is cause of this ?
private void barcodetexbox_KeyDown(object sender, KeyEventArgs e)
{
if (scannedString.Text != "" && e.Key==Key.Return)
{
//do something
}
}
and in “MainWindow.xaml”
<TextBox x:Name="scannedString" HorizontalAlignment="Left" Height="50"
Margin="468,164,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="450"
FontSize="24" Focusable="True" Padding="0,6,0,0"
KeyDown="barcodetexbox_KeyDown" />
The KeyDown event is designed to let you know which keys are down at one moment, and your barcode reader seems to simulate a keyboard, so you’ll need to concatenate the characters it sends
in your Key_Down event, you would have to do something like that:
this.scannedString += e.Key;and when you see return:
barcodeTextBox.Text = this.scannedString;