Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line Numbers & RichTextBox

Status
Not open for further replies.

robdon

Programmer
May 21, 2001
252
ES
Hi,

I am trying to get line numbers on the left side of my RichTextBox.

I thought this would be 'relativly' easy.. set margin, put a picBox on the left and draw the line numbers.

I just cant seem to trap when the user scrolls with the scroll bar, so that I can change the line numbers.

Anyone know how to do this... or a good RichTextBox that includes line numbering.. and other features?

Thanks,

Rob Donovan.
 
You could use SendKeys to move to the beginning of each line and then insert a formatted counter.
 
Hi,

Thansk, but thats not really gonna work for me.

Not only do I want to put in line numbers, I need to display different icons next to different lines.

I also would like the 'line number panel' to have a different colour to the white colour of the text field.

I need to be able to trap all movement/scrolling of the RichTextBox.

Rob.
 
Hi,

Well I'm trying to write an editor for a programming language.

It would be good if I could find a control that works a bit like the VB code window. Ie the popip listbox when you enter a '.' with the properties in it etc.

I could not really find anything on the net.

I've started trying to code it myself, hence this question.

I think I have solved the above problem, I've managed to SubClass the rtb, and that gives me access to the WM_VSCROLL event, then I can keep track of the top line and write the line numbers to a pic control.

The only problem with that, is that when you scroll with the scroll bars, the lines scroll pixel by pixel, I can only detect when a 'whole' line has scrolled, therefor my numbering down the side is a bit 'jerky', and is not always lined up quite correctly.

Thanks,

Rob D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top