473,484 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Create 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.edtTextBody.Lines.Length && i <
iRequestedLineNumber - 1; ++i)
{

charIndex += snpObject.edtTextBody.Lines[i].Length;

}
snpObject.edtTextBody.Select(charIndex, 0);
Nov 15 '05 #1
1 5032
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.SelectionStart=300;
TextBox.SelectionLength=0; //To not show a selectioned area
TextBox.ScrollToCarret();

"Ramsin Savra" <rs****@otxresearch.com> schrieb im Newsbeitrag
news:uS**************@TK2MSFTNGP11.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.edtTextBody.Lines.Length && i <
iRequestedLineNumber - 1; ++i)
{

charIndex += snpObject.edtTextBody.Lines[i].Length;

}
snpObject.edtTextBody.Select(charIndex, 0);

Nov 15 '05 #2

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

Similar topics

8
15221
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...
6
14675
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...
25
2620
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...
7
5755
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
4148
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...
0
1326
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...
4
3279
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...
5
8414
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...
0
7082
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,...
0
6953
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...
0
7105
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,...
0
7144
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6813
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4845
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...
0
3041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1359
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
592
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.