I work with c# windows form vs 2015
i create windows form have 4 textboxes
textbox1,2,3,4 to read data by barcode reader using usb and work as keyboard
I read data from bar code scanner and receive reading in text box 4
but some times it read in textbox2 or textbox3 because cursor mouse moved
so that how to set focus on textbox 4 to read data from scanner ? my code as below
private void textBox4_KeyDown(object sender, KeyEventArgs e)
{
string[] lines = textBox4.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
if (lines.Length > 4)
{
textBox1.Text = lines[1].Substring(lines[1].IndexOf(":") + 1);
textBox2.Text = lines[2].Substring(lines[2].IndexOf(":") + 1);
textBox3.Text = lines[3].Substring(lines[3].IndexOf(":") + 1);
textBox5.Text = lines[4].Substring(lines[4].IndexOf(":") + 1);
}