Click here to Skip to main content
14,219,244 members

AutoBracketsTextBox for brackets auto-completion

Rate this:
4.76 (23 votes)
Please Sign up or sign in to vote.
4.76 (23 votes)
16 Apr 2016LGPL3
Enable brackets & symbols autocompletion

Introduction

Auto-completion & Intellisense are nice features that every developer likes, aren't they? Sadly, there's no such built-in feature as Brackets Autocompletion, so that's why I am proposing this usercontrol in here.

Background

I fell in love with this feature when I used Sublime text editor for the first time , so I am sharing a control that does the same thing.

Implementation

The control contains only 2 objects:

BracketsList: The array that contains the brackets & symbols that will be auto completed.

AllowAutoComplete: You can simply set it to true to activate the feature, or turn it off to disable it.

Using the Code

Easy Usage

  1. Drag & drop the control on your Form.
  2. Go to the properties and edit the brackets list.

Dynamic Usage

Exploiting this user control is pretty easy as the following code shows:

(If you want to create a code editor for example, then you'll need to add some regex patterns, etc.)

AutoBracketsTextBox ABTB  = new AutoBracketsTextBox();
ABTB.Dock = DockStyle.Fill;
ABTB.BracketsList = new[] {  "{" ,  Environment.NewLine + Environment.NewLine + "}"  };
Controls.Add(ABTB);

Samples

Simplest sample.

Simple text editor.

Powerful text editor.

Strings autocomplete sample.

How It Works

In KeyPress event, if the BracketsList contains the char you clicked on, then the ABTB will add the char next to it into the text (it'll respect the position of the caret).

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)

Share

About the Author

Alaa Ben Fatma
Student
Tunisia Tunisia
I am a 19 years old software developer & a university student. I am a curious person, I love learning about new things and meeting more experienced developers & engineers.
alaabenfatma[a]yahoo.fr

Comments and Discussions

 
GeneralGreat... Pin
Pritam Zope1-May-16 10:09
memberPritam Zope1-May-16 10:09 
GeneralRe: Great... Pin
Alaa Ben Fatma7-May-16 4:44
professionalAlaa Ben Fatma7-May-16 4:44 
GeneralMy vote of 5 Pin
Dmitriy Gakh11-Apr-16 22:57
professionalDmitriy Gakh11-Apr-16 22:57 
GeneralRe: My vote of 5 Pin
Alaa Ben Fatma12-Apr-16 8:39
professionalAlaa Ben Fatma12-Apr-16 8:39 
Questionusing this program Pin
Member 124336643-Apr-16 9:23
memberMember 124336643-Apr-16 9:23 
AnswerRe: using this program Pin
Alaa Ben Fatma3-Apr-16 9:55
professionalAlaa Ben Fatma3-Apr-16 9:55 
QuestionQuestion Pin
Mohamed Aziz Lahbecha3-Apr-16 10:02
memberMohamed Aziz Lahbecha3-Apr-16 10:02 
AnswerRe: Question Pin
Alaa Ben Fatma4-Apr-16 11:00
professionalAlaa Ben Fatma4-Apr-16 11:00 
GeneralMy vote of 5 Pin
Member 124336643-Apr-16 5:57
memberMember 124336643-Apr-16 5:57 
GeneralMy vote of 5 Pin
Member 124336663-Apr-16 5:56
memberMember 124336663-Apr-16 5:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Article
Posted 3 Apr 2016

Stats

12.6K views
322 downloads
8 bookmarked