From: AussieRules on
Hi,

I have an application that has a single text box, but many many buttons, and
a few other controls (grid etc).

The problem is that the application has a barcode scanner that acts like a
keyboard. What I need to have is that the text box always has the focus, so
at anytime the barcode scanner is used, the value is in the text box.

If I push a button or slide the grid etc, the focus moves from the text box
to the other control, which means when the bar code scanner scans, the value
is not entered into the text box.

Is there a way to have it so that the txt box always has the focus, yet the
other controls still work ?

From: Cor Ligthert[MVP] on
The most simple one in my idea is to give at every action the textbox focus

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.focus.aspx

I don't think that you can make much automatic code around it, as that will
probably in every action more then using

MyTextBox.Focus

Success

Cor

"AussieRules" <nospam(a)nospam.com> wrote in message
news:Oi5LU71sKHA.6140(a)TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I have an application that has a single text box, but many many buttons,
> and a few other controls (grid etc).
>
> The problem is that the application has a barcode scanner that acts like a
> keyboard. What I need to have is that the text box always has the focus,
> so at anytime the barcode scanner is used, the value is in the text box.
>
> If I push a button or slide the grid etc, the focus moves from the text
> box to the other control, which means when the bar code scanner scans, the
> value is not entered into the text box.
>
> Is there a way to have it so that the txt box always has the focus, yet
> the other controls still work ?

From: eBob.com on

"AussieRules" <nospam(a)nospam.com> wrote in message
news:Oi5LU71sKHA.6140(a)TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I have an application that has a single text box, but many many buttons,
> and a few other controls (grid etc).
>
> The problem is that the application has a barcode scanner that acts like a
> keyboard. What I need to have is that the text box always has the focus,
> so at anytime the barcode scanner is used, the value is in the text box.
>
> If I push a button or slide the grid etc, the focus moves from the text
> box to the other control, which means when the bar code scanner scans, the
> value is not entered into the text box.
>
> Is there a way to have it so that the txt box always has the focus, yet
> the other controls still work ?
I don't understand. TextBox.Text = "whatever" works whether TextBox has the
focus or not. And the assigned value is displayed whether TextBox has the
focus or not.

Bob


From: Onur Güzel on
On Feb 22, 3:31 am, "AussieRules" <nos...(a)nospam.com> wrote:
> Hi,
>
> I have an application that has a single text box, but many many buttons, and
> a few other controls (grid etc).
>
> The problem is that the application has a barcode scanner that acts like a
> keyboard. What I need to have is that the text box always has the focus, so
> at anytime the barcode scanner is used, the value is in the text box.
>
> If I push a button or slide the grid etc, the focus moves from the text box
> to the other control, which means when the bar code scanner scans, the value
> is not entered into the text box.
>
> Is there a way to have it so that the txt box always has the focus, yet the
> other controls still work ?

Do not consider that advice as a brute-force tip, but can't you
consider this:

' Try to handle LostFocus event and re-focus before losing focus
Private Sub TextBox1_LostFocus(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles TextBox1.LostFocus
TextBox1.Focus()
End Sub

It may -not- be useful if your form design deals with another control
pattern based on the user interaction principles.

HTH,

Onur Güzel

From: Cor Ligthert[MVP] on
Hi Onur,

That was the one I forgot,

You are right, but what is brute in the given question?

Cor

"Onur G�zel" <kimiraikkonen85(a)gmail.com> wrote in message
news:15f9385b-ca2d-4723-b675-2c5b47983d3f(a)a18g2000yqc.googlegroups.com...
> On Feb 22, 3:31 am, "AussieRules" <nos...(a)nospam.com> wrote:
>> Hi,
>>
>> I have an application that has a single text box, but many many buttons,
>> and
>> a few other controls (grid etc).
>>
>> The problem is that the application has a barcode scanner that acts like
>> a
>> keyboard. What I need to have is that the text box always has the focus,
>> so
>> at anytime the barcode scanner is used, the value is in the text box.
>>
>> If I push a button or slide the grid etc, the focus moves from the text
>> box
>> to the other control, which means when the bar code scanner scans, the
>> value
>> is not entered into the text box.
>>
>> Is there a way to have it so that the txt box always has the focus, yet
>> the
>> other controls still work ?
>
> Do not consider that advice as a brute-force tip, but can't you
> consider this:
>
> ' Try to handle LostFocus event and re-focus before losing focus
> Private Sub TextBox1_LostFocus(ByVal sender As System.Object, ByVal e
> As System.EventArgs) Handles TextBox1.LostFocus
> TextBox1.Focus()
> End Sub
>
> It may -not- be useful if your form design deals with another control
> pattern based on the user interaction principles.
>
> HTH,
>
> Onur G�zel
>