Solved

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

Posted on 2008-10-07
3
204 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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