|
-
Jul 18th, 2004, 07:19 PM
#1
Thread Starter
Hyperactive Member
VB.NET Proper Case
I use this code so that the text of the TextBox1 will change to Proper Case;
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = StrConv(TextBox1.Text, VbStrConv.ProperCase)
SendKeys.Send("{End}")
End Sub
But the problem of this code, When I type "HELLO" and i will going to erase "E" using backspace, the cursor goes to the end (at the right side of O).
Anybody has a better idea for this?
-
Jul 19th, 2004, 04:46 AM
#2
Retired VBF Adm1nistrator
You could check what the key pressed was. So if it was backspace, or any other special key, then don't go to end.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Jul 19th, 2004, 04:48 AM
#3
PowerPoster
Hi,
Sorry, I can't see the problem. You can place the cursor where you want by using the cursorleft and cursor right keys or the mouse. Obviously, the moment you delete a character you fire the TextChanged event and your proper case routine re-writes the textbox.text.
Where do you want the cursor to finish?
By the way, I had to use
VB Code:
SendKeys.SendWait("{End}")
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jul 19th, 2004, 06:00 AM
#4
Hyperactive Member
I have hardly fighted with real time control of input in textbox and I know that put cursor where you want to find it, is not an easy thing. Anyway, basically you have to acquire cursor position:
Dim SS as byte
SS=Textbox1.SelectionStart
then you have to calculate where it have to finish after changing is done, modify SS, and put it there with code like this
TextBox1.SelectionStart=SS
Good luck!
Live long and prosper (Mr. Spock)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|