473,382 Members | 1,775 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,382 software developers and data experts.

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.Text = FormatNumber(RichTextBox1.GetLineFromCharIndex(Ric hTextBox1.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 1775
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.SelectionStart(
Do While x >
If RichTextBox1.Text.Chars(x-1) = vbLF Then Exit Do Else x -=
Loo
Return (RichTextBox1.SelectionStart() - 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.SelectionStart(
Do While x >
If RichTextBox1.Text.Chars(x-1) = vbLF Then Exit Do Else x -=
Loo
Return (RichTextBox1.SelectionStart() - 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
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...
2
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
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). ...
0
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...
1
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 =...
1
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...
10
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
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...
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.