Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tabing on a form

0 views
Skip to first unread message

William

unread,
May 6, 2003, 5:47:45 PM5/6/03
to
Right now the tab key goes from control to control and
selects all the text in the given control. I want to
prevent the selection of all the text and just put the
cursor there. Do i have to put code in EVERY keypress
event for every control?

Please no no no no say it isnt so

Pete Davis

unread,
May 6, 2003, 7:18:50 PM5/6/03
to
Well, first of all, this is standard windows behavior, and if you're going
to override it, you ought to think about whether or not you have a
compelling reason for doing it. Remember, MS probably spends more money on
usability testing than most companies will ever see.

If a compelling reason exists to make the change, the simplest way to do it
would be to derive a text box class from the system text box, and handle it
in your derived class. Then use that class instead of the textbox class
provided by the framework.

But again, think twice before doing it.

Pete

"William" <wne...@4psp.com> wrote in message
news:072801c31419$20c70e40$3001...@phx.gbl...

Lubos Hrasko

unread,
May 6, 2003, 7:25:41 PM5/6/03
to
no no no no, it isn't so. There I said it! :)

I am assuming that you are talking about a text controls... Why don't you
just write a generic event handler for each control type (text, list, etc.)
and assign it to many events:

Example:

Private Sub txtBody_Enter(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles txtBody.GotFocus, txtBudgetCode1.GotFocus, ETC....

'your code here

End Sub

Cheers,
Lubos

"William" <wne...@4psp.com> wrote in message
news:072801c31419$20c70e40$3001...@phx.gbl...

Lubos Hrasko

unread,
May 6, 2003, 7:37:14 PM5/6/03
to
Hmm... I like Pete's suggestion better of deriving a class..


"Lubos Hrasko" <lu...@NO-microcafe.net-SPAM> wrote in message
news:e9WYabCF...@TK2MSFTNGP10.phx.gbl...

Jakob Bengtsson

unread,
May 7, 2003, 5:58:26 AM5/7/03
to
You can easily assign a common handler for all textboxes
on your form. Create two simple subs (see below), and
call "addTextboxHandlers" from your forms load event
procedure (or anywhere else you feel it makes sense)

Jakob.

The subs:
---------
Private Sub addTextboxHandlers()
Dim t As TextBox
For Each t In Me.Controls
AddHandler t.GotFocus, AddressOf
TextBoxes_GotFocus
Next
End Sub
Private Sub TextBoxes_GotFocus(ByVal sender As

Object, ByVal e As System.EventArgs)

Dim txt As TextBox = CType(sender, TextBox)
With txt
.SelectionStart = 0
.SelectionLength = 0
End With
End Sub

>.
>

0 new messages