473,805 Members | 2,016 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 1809
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
11746
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
3354
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
6074
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
1388
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
1570
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
1643
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
6579
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
9716
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
10607
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...
1
10364
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10104
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
6875
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
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4317
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
2
3843
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
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.