473,549 Members | 3,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to move a cursor to a specific line in a text box?


Hi, I have below code, to move the cursor to a specific line in a text-box
control (I don't want to use RichTextBox) but doesn't work! any suggestions?
int charIndex = 1;
for (int i = 0; i < snpObject.edtTe xtBody.Lines.Le ngth && i <
iRequestedLineN umber - 1; ++i)
{

charIndex += snpObject.edtTe xtBody.Lines[i].Length;

}
snpObject.edtTe xtBody.Select(c harIndex, 0);
Nov 15 '05 #1
1 5041
Once I red over a little trick, you have to set the SelectionStart propriety
equals the text postion to show and use the ScrollToCarret method to show it

TextBox.Selecti onStart=300;
TextBox.Selecti onLength=0; //To not show a selectioned area
TextBox.ScrollT oCarret();

"Ramsin Savra" <rs****@otxrese arch.com> schrieb im Newsbeitrag
news:uS******** ******@TK2MSFTN GP11.phx.gbl...

Hi, I have below code, to move the cursor to a specific line in a text-box
control (I don't want to use RichTextBox) but doesn't work! any suggestions?

int charIndex = 1;
for (int i = 0; i < snpObject.edtTe xtBody.Lines.Le ngth && i <
iRequestedLineN umber - 1; ++i)
{

charIndex += snpObject.edtTe xtBody.Lines[i].Length;

}
snpObject.edtTe xtBody.Select(c harIndex, 0);

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
15227
by: Hung Huynh | last post by:
Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to work. For example, I have 10 records in my rsData recordset, and I issue this command rsData.Move 5, 1 'move to #5 from beginning
6
14683
by: Terry | last post by:
I have a form which is displayed in Datasheet View and would prefer it if, when entering data, I could use the keyboard as I would when entering data into a Datasheet. Is it possible when entering data into a form to get the cursor to move to the next control after I press the Enter key? Terry
25
2635
by: JeffS | last post by:
Honest, I scoured the comp.lang.c.faq for this but found nothing. :) Is there a library function for placing the cursor position in the console? Or is it something that can only be done with a platform API call? I was able to do this in Windows with a Windows.h function, but I want to also do it on Linux/Unix as well. I won't ask for...
7
5763
by: Seash | last post by:
Hi friends , here is the sample code private void txtbox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus(); }
1
4157
by: Stefan Mueller | last post by:
With the following code I can change the mouse pointer. However, if you click in Mozilla (with IE it works perfect) on 'Show hourglass' the mouse pointer changes only if you move the mouse at least on pixel. <html> <body> <script type = 'text/javascript'> function show_hourglass() { document.getElementById("my_href1").style.cursor =...
0
1335
by: Rahna | last post by:
Hi, I'm using the DirectSS1 Speech Control in my VB 6 application. I tried to use the WordPosition Event to move the cursor along with the speech. the code goes like this Private Sub DirectSS1_WordPosition(ByVal hi as long, ByVal lo as long, ByVal ByteOffset as long) RichTextBox1.SelStart=ByteOffset/2
4
3292
by: yan.python | last post by:
i have a question. when i run Interactive Interpreter in linux command promt,how can i move the cursor. for example,when i enter a string,i often enter the quotation mark "" first,and the move the cursor inside the mark to enter the string,in windows,it is ok.but when i do that in linux,pressing the "left" key will just print "^[[D" in the...
5
8434
by: michels287 | last post by:
Right now I have a touchscreen with a virual keyboard. I would like to create arrow keys. If the user messed up the inputted text, he can move the blinking cursor left one space at a time between inputted characters to add a letter. Then a button to move the blinking cursor back to the end of the inputted text. Private Sub Left...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7718
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6041
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.