From: Fred on


"AussieRules" <nospam(a)nospam.com> a �crit dans le message de groupe de
discussion : 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 ?

Perhaps you can use Form.KeyPreview property and Form.KeyDown event ?

--
Fred
foleide(a)free.fr

From: Onur Güzel on
On Feb 22, 7:46 pm, "Cor Ligthert[MVP]" <Notmyfirstn...(a)planet.nl>
wrote:
> Hi Onur,
>
> That was the one I forgot,
>
> You are right, but what is brute in the given question?
>
> Cor
>
> "Onur Güzel" <kimiraikkone...(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

Hi,
I just meant that this technique may not be desirable by clients
(users of application) and whether the OP's form design is suitable
for this. Forcing users to accept a mandatory application behaviour
may annoy them. But if it's a private application (which is not
deployed to any clients and will be used in his own company) or that
is meant to be used by author, it seems useful.

Onur Güzel