473,796 Members | 2,607 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determining RichTextBox Current Column Location

DMD
How do I determine the column associated with the current edit location within a RichTextBox? The following code allow
me to determine the current line

txtLineNumber.T ext = FormatNumber(Ri chTextBox1.GetL ineFromCharInde x(RichTextBox1. SelectionStart( ))+1,0

How do I determine the column location within the line? I must be missing something obvious, any help would be appreciated

Jul 21 '05 #1
2 1808
DMD
Well I decided to fiddle around with the text files is was dealing with and came up with thi
option

Dim x As Integer = RichTextBox1.Se lectionStart(
Do While x >
If RichTextBox1.Te xt.Chars(x-1) = vbLF Then Exit Do Else x -=
Loo
Return (RichTextBox1.S electionStart() - x

Just backs-up from the current entry point until it hits a Line Feed character. Th
distance between the insertion point and the beginning of the line is returned.
Obvious pit-fall is the character which is intercepted when the end of the curren
line is encountered. If x=0, all text has been read.

If anyone has ideas to improve this option, or has an improved solution, an
contribution would be appreciated.
Jul 21 '05 #2
DMD
Well I decided to fiddle around with the text files is was dealing with and came up with thi
option

Dim x As Integer = RichTextBox1.Se lectionStart(
Do While x >
If RichTextBox1.Te xt.Chars(x-1) = vbLF Then Exit Do Else x -=
Loo
Return (RichTextBox1.S electionStart() - x

Just backs-up from the current entry point until it hits a Line Feed character. Th
distance between the insertion point and the beginning of the line is returned.
Obvious pit-fall is the character which is intercepted when the end of the curren
line is encountered. If x=0, all text has been read.

If anyone has ideas to improve this option, or has an improved solution, an
contribution would be appreciated.
Jul 21 '05 #3

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

Similar topics

3
11742
by: AttiDude | last post by:
Hi, I have some difficulties when adding text to a (multiline)richtextbox, to change the color of that line only. Changing colors on parts of text you want, need to be selected to change color. So I need to create a code that selects the text I just added to the richtextbox for a very short period so the user doesn't notices.
2
3353
by: Nathan | last post by:
In a RichTextBox, how do you get/set the current location of the blinking cursor (not the mouse cursor)? Thanks
2
6072
by: Clark Stevens | last post by:
Hi. This should be so easy, but I don't get it. Let say I have RichTextbox1 and I want to insert some text at the current insertion point, or at the beginning of selected text (if there is any). How is this done? Also, how do I delete the current selection? Thanks.
0
1387
by: Ben | last post by:
module main ... application.run(new splashform) .. end module after a few screen, I try to load a new codes I got from MSDN on datagrid that works on its own. I took out submain and ran datagridForm from my mainForm:
1
289
by: DMD | last post by:
How do I determine the column associated with the current edit location within a RichTextBox? The following code allow me to determine the current line txtLineNumber.Text = FormatNumber(RichTextBox1.GetLineFromCharIndex(RichTextBox1.SelectionStart())+1,0 How do I determine the column location within the line? I must be missing something obvious, any help would be appreciated
1
1567
by: sunrise | last post by:
I've been playing around the RichTextBox and reading a few articles, in order to create a text editor like Notepad++ in C#. To be frank, I'm very disappointed by the RichTextBox control capabilities. What I've been looking for is: - What's the current row/line - What's the current column - Highlight the latest word - Change the font specification to a selected area only
10
1641
by: Peter Olcott | last post by:
Someone told me that determining the exact location and current state of any JavaScript controls is pretty easy. Does anyone know exactly how this is done?
13
6577
by: dennis | last post by:
Hello, I'm having trouble solving the following problem with DB2 UDB 8.2. I need to create a trigger that performs certain extra constraint validations (temporal uniqueness). One of the tables has no primary key. I'm having trouble expressing an update trigger that checks for existing rows, contemporary to the updated one, but exclusing the
2
9781
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, I have a somewhat long calculation report printed out in a RichTextBox. To find or monitor a particular value, users scroll down to the location of the data in the RichTextBox. However, when the user changes the input data, a recalculation is made and a new report is generated. This resets the RichTextBox vertical scroll bar to the top. I would like to be able to read the position the scroll bar is moved to before recalculation....
0
9685
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
9531
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
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
10237
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...
1
7553
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
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
5446
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...
1
4120
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 we have to send another system
3
2928
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.