?
Solved

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

Posted on 2008-10-07
3
Medium Priority
?
212 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 1000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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 …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 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