문제

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"  />

올바른 솔루션이 없습니다

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top