Solved

is there any way to set the cursor in a textbox after setting the .Text property?

Posted on 2008-10-07
3
208 Views
Last Modified: 2010-04-23
I have a textbox control which I use the TextChanged event to filter out certain keypresses which I don't want to show by taking the text as a string with each keypress and filtering out any unwanted chars. The problem is that when I insert the string back into the textbox, the cursor is always at the end of the current string. Is there anyway to remember the cursor position so the user can edit the string? On second thought, I may have to rethink my whole approach.

Dan
0
Comment
Question by:zliminator
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 250 total points
ID: 22660391
Cursor position can be readed and writed using SelectionStart property. Try it.
0
 

Author Comment

by:zliminator
ID: 22661026
I found a SelectionStart property for the ComboBox but not for the TextBox. I'm using .Net 2.0. Is this new to 3.x? I tried it like this:
Private Sub DisplayTextBox_TextChanged(ByVal sender As System.Object, ByVal e As    System.EventArgs) Handles DisplayTextBox.TextChanged
        Dim x As Integer = DisplayTextBox.SelectionStart
but it allway gives 0

Dan
0
 

Author Comment

by:zliminator
ID: 22661083
OK, I can set it but I can't get it. All I need to do, really, is set it. I'm happy.

Dan
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question