473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1595
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.U serControl 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.U serControl 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
10105
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, buttons, ect. I would like to catch/add a handler/recieve the Button.OnClick event from the buttons that are in the user control, in the Page. How?...
1
2300
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, EnsureChildControls gets called, creating the control before the UserControl is even added to the webform. The problem with this is that the...
8
1952
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 that category, the results are paged 10 to a page and the user can page them. As this "Category" usercontrol hardly ever changes I wanted to setup...
41
4269
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 on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. ...
12
2186
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 server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places...
9
14431
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 does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same...
6
12125
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 binding like normal. The problem I am running into is that my UserControl ends up with a different BindingContext then the ParentForm it is...
3
2010
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 buffering and removed all code in the OnLoad, constructor and I still have the same problem. Here is the code that I use to display the UserControl un...
2
8612
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 same problem. Here is a complete example: http://forums.asp.net/thread/1555836.aspx Related to this: (But I am not doing dynamic user control...
0
7612
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7970
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...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2113
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
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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...

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.