Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make custom controls in C#? [closed]

So I'm working on a C# program that functions something like an IDE. The thing is, I'm doing it through a rich text box the custom syntax highlighting is SUPER inefficient.

I was wondering if there was a way to make a custom control similar to a rich text box (even based off of one) and then build in the syntax highlighting in an easier way...

So, how do I make custom controls? And if you were super nice, you'd point me in the direction of a good tutorial on it!

like image 695
Alper Avatar asked Jun 19 '11 22:06

Alper


People also ask

What are custom controls?

A software routine that adds some enhancement or feature to an application. Custom controls are written to provide as little as a few graphical interface improvements to as much as providing full imaging, spreadsheet and text editing extensions to the application.

How do I add different controls to my form?

Add the control by drawing Select the control by clicking on it. In your form, drag-select a region. The control will be placed to fit the size of the region you selected.


3 Answers

Simple but functional examples:

Windows Forms:

http://www.codeproject.com/KB/miscctrl/cutebutton.aspx

WPF:

http://msdn.microsoft.com/en-us/library/cc295235.aspx

like image 133
Erre Efe Avatar answered Nov 01 '22 18:11

Erre Efe


easily just derive from base control

public class CustomRichTextBox:RichTextBox
{
    public CustomRichTextBox()
    {
        this.Multiline = true;
        this.WordWrap = false;
        this.AcceptsTab = true;
        //...
    }
}
like image 22
Navid Rahmani Avatar answered Nov 01 '22 19:11

Navid Rahmani


I would suggest looking at some tutorials such as

http://www.codeproject.com/KB/miscctrl/cutebutton.aspx

As NavidRahmani said just above, you dont have to start from scratch you can extend existing control or use controls that are already made from different libraries.

Such as telerik controls.

like image 37
Luke Avatar answered Nov 01 '22 18:11

Luke