Question

I have a barcode which contains two input fields that I want to scan into two textbox fields in my wpf application. But when I scan, all input goes to first textbox which has focus.

If I scan input into Excel or notepad, its corrected scanned into different cells (or lines).

Here is what I have about my Textboxes:

<TextBox KeyboardNavigation.TabIndex="0"  x:Name="artTB" Height="30" />
<TextBox KeyboardNavigation.TabIndex="1"  x:Name="snTB" Height="30" />
<TextBox KeyboardNavigation.TabIndex="2"  x:Name="snplcTB" Height="30"  />

No correct solution

OTHER TIPS

I don't know how you want your bar code split up, but you could try doing it in the TextBox.TextChanged event?:

private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
    TextBox focusedTextBox = (TextBox)sender;
    string barCode = focusedTextBox.Text;
    TextBox1.Text = barCode.Substring(0, 3);
    TextBox2.Text = barCode.Substring(3, 3);
    TextBox3.Text = barCode.Substring(6, 3);
}

So the idea is to scan into one TextBox and just copy the relevant part of the scanned bar code to the relevant TextBox.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top