473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Textbox goto

I have a multi-line text box and a button. the textbox displays a large text
file about 1000line

I want the textbox to goto say line 324 (line 324 is now the first line in
the textbox) when the button is clicked.
What's the command to do this?

THanks
Nov 16 '05 #1
1 3279
> I want the textbox to goto say line 324 (line 324 is now the first line in
the textbox) when the button is clicked.
What's the command to do this?


You can use the ScrollToCaret() method however you'll need to find the
character position of the line where you want to scroll. This can be done by
using the EM_LINEINDEX API call (fast) or simply by enumerating the lines
(slow). I'm going for the slow one :o)

textBox1.SelectionStart = FindCharacterPos(tb, 324);
textBox1.SelectionLength = 0;
textBox1.ScrollToCaret();

public int FindCharacterPos(TextBox tb, int lineNo) {
if (tb.Lines.Length < lineNo) {
return -1;
}

int pos = 0;
for (int i = 0; i < lineNo; i++) {
pos += tb.Lines[i].Length;
}
return pos;
}
Rgd,
Peter Theill - http://www.theill.com/
Nov 16 '05 #2

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

Similar topics

30
by: Hayri ERDENER | last post by:
hi, what is the equivalent of C languages' goto statement in python? best regards
37
by: Tim Marshall | last post by:
From http://www.mvps.org/access/tencommandments.htm 9th item: Thou shalt not use "SendKeys", "Smart Codes" or "GoTo" (unless the GoTo be part of an OnError process) for these will lead you...
6
by: Oren | last post by:
Hi, Is there a way to use the SelStart functionality in a textbox that has more than 32,767 characters in it, when the cursor is beyond the 32,767th characterz? SelStart is an integer, and it...
4
by: MLH | last post by:
The error occurs in the If-line of this procedure. ReasonTowed is NOT a form, a report or a label control. It is a textbox. I admit that it is a volatile time to be checking a textbox value. And,...
1
by: Aaron | last post by:
I have a multi-line text box and a button. the textbox displays a large text file about 1000line I want the textbox to goto say line 324 (line 324 is now the first line in the textbox) when the...
77
by: M.B | last post by:
Guys, Need some of your opinion on an oft beaten track We have an option of using "goto" in C language, but most testbooks (even K&R) advice against use of it. My personal experience was that...
34
by: electrician | last post by:
Perl has it, Basic has it, Fortran has it. What is so difficult about creating a goto command for JavaScript. Just set up a label and say go to it.
7
by: robert.waters | last post by:
I have an Access database frontend linked via ODBC to a large (gigabytes) mysql database. I need to view a large amount of data in a a textbox (variable up to 300K), but I receive a 'there isnt...
59
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
1
by: vaniKanabathy | last post by:
I need to call back what i had write in notepad using vb application. I can do it using the coding below but the problem is i want to retrive the value in different textbox but all the values in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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...
0
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...

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.