Dan,
Keep in mind that in VB.NET, all controls are dynamically created.
Therefore there is nothing unusual or inefficient about looping through the
Form's Controls collection at run-time. For each textbox, you may either
apply Shawn's solution (best) or dynamically attach your KeyPress event
handler, like this:
AddHandler objTextBox.KeyPress, AddressOf frm_KeyPress
Bill
On Wed, 24 Apr 2002 00:55:16 -0400, Shawn Wildermuth
<[EMAIL PROTECTED]> wrote:
>Why not just set the CharacterCasing property of your TextBox's? You
>can set it in the Property window or with code:
>
>textBox1.CharacterCasing = CharacterCasing.Upper
>
>Thanks,
>
>Shawn Wildermuth
>[EMAIL PROTECTED]
>
>> -----Original Message-----
>> From: dotnet discussion [mailto:[EMAIL PROTECTED]]
>> On Behalf Of Dan Souk
>> Sent: Wednesday, April 24, 2002 12:27 AM
>> To: [EMAIL PROTECTED]
>> Subject: [DOTNET] KeyPress
>>
>>
>> I need to ensure that all characters are forced to upper case
>> for nearly all data entry forms in a VB.NET app. Thought I'd
>> try to do it via the KeyPress event, but since arguments are
>> passed by value, not reference, I'm stuck.
>>
>> In VB6, the ASCII keycode is passed by ref as an integer, and
>> it was easy to ensure upper case via the following code:
>>
>> Sub KeytoUCase(intKey As Integer)
>> Dim strChar As String
>> strChar = Chr(intKey)
>> intKey = Asc(UCase(strChar))
>> End
>>
>> VB.NET's event signature is this:
>>
>> Private Sub frm_KeyPress(ByVal sender As Object, ByVal e As
>> System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
>> e.Handled = True
>> 'READ ONLY!!
>> 'e.KeyChar = basGUIUtils.KeytoUCase(AscW(e.KeyChar))
>> End Sub
>>
>> Any thoughts on how to do this, without having to touch every
>> individual control?
>>
>> ------------------------
>> Dan Souk
>> Finna Technologies, Inc.
>> 2410 Lindsay Ct
>> West Chicago, IL 60185
>> +1-630-762-8257 phone
>> +1-630-762-8258 fax
>> http://www.finnatech.com
>>
>> You can read messages from the DOTNET archive, unsubscribe
>> from DOTNET, or subscribe to other DevelopMentor lists at
>> http://discuss.develop.com.
>>
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.