473,672 Members | 2,762 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 3297
> 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.Select ionStart = FindCharacterPo s(tb, 324);
textBox1.Select ionLength = 0;
textBox1.Scroll ToCaret();

public int FindCharacterPo s(TextBox tb, int lineNo) {
if (tb.Lines.Lengt h < 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
4266
by: Hayri ERDENER | last post by:
hi, what is the equivalent of C languages' goto statement in python? best regards
37
3240
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 from the path of righteousness. What about also using it as a means of exiting a procedure?
6
8822
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 wraps around to negative numbers when going beyond this upper limit. Thanks,
4
2123
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, the fact may be that even as a textbox, that during this time it is an object that has no value. Whaddaya think? Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)...
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 button is clicked. What's the command to do this? THanks
77
4002
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 goto sometimes makes program some more cleaner and easy to understand and also quite useful (in error handling cases). So why goto is outlawed from civilized c programmers community. is there any technical inefficiency in that.
34
26627
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
2891
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 enough memory' error whenever I scroll past N number of bytes in a textbox that has been filled with a lot of data. I am not sure what N is, but for a large chunk of data it occurs at about the halfway scroll, and smaller chunks might not throw...
59
5036
by: raashid bhatt | last post by:
why are GOTO's not used they just a simple JMP instructions what's bad about them
1
3158
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 notepad appear in 1 textbox.Like in notepad i got values like f g In textbox the values appear like Text1 = fg Text2 = fg Actually i want like Text1 = f Text2 = g
0
8486
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8932
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8831
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8683
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5707
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4230
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1819
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.