none
BarCode Readers And C# RRS feed

  • Question

  • Hi
    As many of u guys may have worked with BarCode readers like dataLogic or any other brands , You may know that they work like KeyBoards and your form must focus on one of your textBoxes or other inputs to be able to get the BarCode Strings . My questin is , are there any method that the form can be watchfull for incoming string regardless the forms focus , I dont want to restrict user to pay attention to textbox focus , I want an event to be fired whenever an string is coming .
    Thank you
    Sunday, November 22, 2009 12:28 PM

Answers

  • Hi,

    You might need to use a timer to active the form and focus the textbox. the timer will be started when the form is deactivated.
    Please try the code below:

         private void Form1_Deactivate(object sender, EventArgs e)
            {
                t.Start();                             
            }
            Timer t;
            private void Form1_Load(object sender, EventArgs e)
            {
                t = new Timer();
                t.Interval =100;
                t.Tick += new EventHandler(t_Tick); 
            }
            void t_Tick(object sender, EventArgs e)
            {
                this.ActivateApplication();
                this.textBox1.Focus();
                t.Stop();
            }

    You might also want to use a bool to indicate wether the timer should work .

    Harry


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Harry Zhu Monday, November 30, 2009 5:32 AM
    Thursday, November 26, 2009 6:55 AM