473,513 Members | 8,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3285
> 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
4226
by: Hayri ERDENER | last post by:
hi, what is the equivalent of C languages' goto statement in python? best regards
37
3212
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
8778
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
2110
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
456
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
3955
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
26596
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
2877
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
4991
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
1
3152
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
7254
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
7153
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
7432
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
7094
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...
0
7519
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...
0
5677
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,...
0
3230
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...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
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.