PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Capital letters in Textbox
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Capital letters in Textbox
![]() |
Capital letters in Textbox |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Public Declare Function GetFocus Lib "Coredll" () As
Integer Public Declare Function GetWindowLong Lib "Coredll" Alias "GetWindowLongW" (ByVal hwnd As Integer, ByVal nIndex As Integer) As Integer Public Declare Function SetWindowLong Lib "Coredll" Alias "SetWindowLongW" (ByVal hwnd As Integer, ByVal nIndex As Integer, ByVal dwNewLong As Integer) As Integer Const GWL_STYLE = -16 Const ES_NUMBER = 8192 Const ES_UPPERCASE = 8 Const ES_LOWERCASE = 16 Public Function EnsureNumeric(ByVal pTextBox As TextBox, ByVal Force As Boolean) Dim hWnd As Integer Dim Style As Integer Try pTextBox.Focus() hWnd = GetFocus Style = GetWindowLong(hWnd, GWL_STYLE) If Force Then Style = Style Or ES_NUMBER Else Style = Style And Not ES_NUMBER End If SetWindowLong(hWnd, GWL_STYLE, Style) Catch End Try End Function Public Function EnsureUpperCase(ByVal pTextBox As TextBox) Dim hWnd As Integer Dim Style As Integer pTextBox.Focus() hWnd = GetFocus Style = GetWindowLong(hWnd, GWL_STYLE) Style = Style Or ES_UPPERCASE SetWindowLong(hWnd, GWL_STYLE, Style) End Function >-----Original Message----- >Hi >Does anybody know how to make textbox to display always >text in capital letters even if Caps Lock is Off. Maybe >somebody knows how to turn Caps Lock ON programatically. > >Thank You for any answer > >Jacek >. > |
|
|
|
#2 |
|
Guest
Posts: n/a
|
There's a MUCH simpler way....
In the TextChanged event of the textbox, do something like this: // Convert Text to upper case textBox1.Text = textBox1.Text.ToUpper(); // Move cursor to end of Text textBox1.SelectionStart = textBox1.Text.Length; HTH Neil -- Neil Cowburn Microsoft Windows Embedded MVP Content Master Ltd www.contentmaster.com "Kenan" <kenanmengu@hotmail.com> wrote in message news:04d701c3452d$e2964690$a001280a@phx.gbl... > Public Declare Function GetFocus Lib "Coredll" () As > Integer > > Public Declare Function GetWindowLong Lib "Coredll" > Alias "GetWindowLongW" (ByVal hwnd As Integer, ByVal > nIndex As Integer) As Integer > > Public Declare Function SetWindowLong Lib "Coredll" > Alias "SetWindowLongW" (ByVal hwnd As Integer, ByVal > nIndex As Integer, ByVal dwNewLong As Integer) As Integer > > Const GWL_STYLE = -16 > Const ES_NUMBER = 8192 > Const ES_UPPERCASE = 8 > Const ES_LOWERCASE = 16 > > Public Function EnsureNumeric(ByVal pTextBox As > TextBox, ByVal Force As Boolean) > Dim hWnd As Integer > Dim Style As Integer > Try > pTextBox.Focus() > hWnd = GetFocus > > Style = GetWindowLong(hWnd, GWL_STYLE) > If Force Then > Style = Style Or ES_NUMBER > Else > Style = Style And Not ES_NUMBER > End If > SetWindowLong(hWnd, GWL_STYLE, Style) > Catch > End Try > End Function > > Public Function EnsureUpperCase(ByVal pTextBox As > TextBox) > Dim hWnd As Integer > Dim Style As Integer > > pTextBox.Focus() > hWnd = GetFocus > > Style = GetWindowLong(hWnd, GWL_STYLE) > Style = Style Or ES_UPPERCASE > SetWindowLong(hWnd, GWL_STYLE, Style) > End Function > > > > > >-----Original Message----- > >Hi > >Does anybody know how to make textbox to display always > >text in capital letters even if Caps Lock is Off. Maybe > >somebody knows how to turn Caps Lock ON programatically. > > > >Thank You for any answer > > > >Jacek > >. > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

