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

UserControl Creation Help!

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
Nov 15 '05 #1
2 1582
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

On Sun, 5 Oct 2003 14:49:27 -0700, "Matt Rudder"
<ma**@cypher-edge.com> wrote:
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


Nov 15 '05 #2
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

On Sun, 5 Oct 2003 14:49:27 -0700, "Matt Rudder"
<ma**@cypher-edge.com> wrote:
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


Nov 15 '05 #3

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

Similar topics

4
by: Andy | last post by:
Alright, I am beyond confused here and need some guidance. I need a C# only sample. I have a simple Page and within it i am creating a user control (ascx). The user control contains textboxes,...
1
by: Kepler | last post by:
I have a custom control that is thrown onto a UserControl that is thrown onto a WebForm. Basically, I've got a scenario where if my UserControl sets an attribute on the custom control in the ascx,...
8
by: Raed Sawalha | last post by:
Hi, I have a strange problem with a usercontrol on a page. The usercontrol dispalyes three categories (From a database) when the user clicks a category they see all the products in a shop for...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
12
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
6
by: MeowCow | last post by:
I have created a UserControl that encapsulates a third party data grid. My goal was to create my own DataSource and DataMember properties that forward the binding to the third party grid, then use...
3
by: Martin | last post by:
Hi ! I've developed a small UserControl with five textbox and label. However, when I want to display the UserControl in a form, controls appear slowly one after one. I've activated double...
2
by: Wayne Brantley | last post by:
If you expose a public property of a usercontrol that accesses an object on the user control it will give a null reference exception when you wrap that in an update panel. Others are having the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.