UserControl Creation Help!

  • Thread starter Thread starter Matt Rudder
  • Start date Start date
M

Matt Rudder

Hello all,

I'm currently writing a program in which I need a textbox control, similar
to the code editor in .NET. but with line numbers and such. I can't find
anything third-party that even comes close to what I want to do, so I
figured I'd have to write one myself.

I started first by inheriting from a RichTextBox, but I want to be able to
scroll line by line in the control instead of pixel by pixel, and I couldn't
figure out a way to make that happen. Also, I had a hard time making the
line numbers, line up with their line of text.

Then, I tryed started from scratch, and I pretty much got it working, but
scrolling is incredibly slow, as I'm using GDI+ to draw the text, and all
the lines needed.

Am I going about this all wrong? It seems like there should be a better way
to do it, but I'm not sure. If anyone here could point me in the right
direction, that would be great.

Thanks,
Matt Rudder
 
avoid using the RichTextBox for anything custom. The RTB is a great
control if you need a lot of functionality built in but is almost
entirely non-customizeable.

If you are really needing to do it from scratch I suggest you start
with the Windows.Forms.UserControl object and work on optimizing the
draw routines so you only 'display' items that are currently in view.

To get the line numbers to line up correctly (assuming you mean
vertical line up) then make sure you use a fixed font like FixedSys so
everything lines up as if each letter were in a box.

hope that helps
Allen Anderson
http://www.glacialcomponents.com
 
Back
Top