0

I was working on a custom control which it was supposed to be a textbox. After some struggling, I did it till the middle of the work but I deleted it at last. My question is, "Is there any article or topic related to designing UIs and specially textbox designing?". I found some good sources about doing this but it's always hard to fit your foot in another person shoe!

An idea that I came up with is creating a structure of Char which it's gonna hold a character properties and a list of these Chars to track every character position and style. I know the textbox itself is consisted of rows and columns of characters but it's just the concept, how you gonna make it?

EDIT The aim is to create a flexible control for drawing all kinds of materials on it. I checked the methods with overriding the Paint event of controls but they're not gonna fill my needs. A real good example of my speech is Fast Colored Textbox. I chose this example because it's really my problem. I did a lot syntax highlighters with RichTextBox, but it would make bugs at working with huge texts. I hope you've got my aim.

6
  • 6
    Probably not, given that there's little to no point. Windows already provides a TextBox control with all the little bugs ironed out already. Don't reinvent the wheel, yours is very likely to be hexagonal. Commented Jan 31, 2012 at 20:41
  • Why do you want to create your own? What features does the standard Windows text box lack that you need? Commented Jan 31, 2012 at 20:43
  • So if someone wanted to have an extra feature on his textbox, what should he do? Commented Jan 31, 2012 at 20:45
  • Derive your control from the TextBox control and add whatever features you need. Commented Jan 31, 2012 at 20:47
  • 2
    This is a pretty hard problem. I think we cannot give a solution that is less than 5 pages... Commented Jan 31, 2012 at 20:56

3 Answers 3

2

If you want a simple TextBox with some extended cappabilities, just derive from built-in one:

public MyCustomTextBox : System.Windows.Forms.TextBox 
{
    //an implementation of extended cappabilities
}

If you want multiline complex editor (and not just simple TextBox) look on

AvalonEidt, the WPF based editor used in SharpDevelop.

If you want to write your own one (I presume for study purpose, if not there is no any reason to reinvent the stuff already done), study basic operations :

  • characters sequence management
  • files management
  • CRUD operations

and begin to write your own.

Good luck.

Sign up to request clarification or add additional context in comments.

3 Comments

Or the appropriately-named RichTextBox control.
The intentions of OP are not very clear to me. Considering Avalon is good for learning purposes. Really good project and big study material to learn a lot of things on industrial level code/text editors written in C#.
Hey thanks. I checked it some months ago, that's a real stuff.
1

As already noted by the comments here and there, reusing existing functionality is always better than recreating something that already exists. (i.e. reinventing the wheel)

You've got the standard TextBox (like noted by Tigran), the RichTextBox (Cody Gray) and several others. Although these are all a bit nasty to customize, overriding the events like Paint() and so on might give you access to the customization you need.

If your UI really wants to look different from the traditional Windows Forms layout, I don't think a textbox is the only control you want to customize... You might want to try Windows Presentation Foundation. Windows Forms wasn't designed with custom UI look & feel in mind, but WPF certainly is! (You can host WPF elements in a windows forms app.)

From all the UI elements out there, a textbox is certainly one of the harder ones. It might help if you elaborate a bit on what you are trying to achieve with your textbox...

1 Comment

Not really, I'm not going to change the whole theme. I was just asking for a resource to find out the idea behind the textbox control and designing one for my own needs. I edited my question, there is a source that shows what am I talking about.
1

If you want to do it yourself...

Some data structures (in particular http://en.wikipedia.org/wiki/Flyweight_pattern ) is discussed in relation to storing text in the book : Design Patterns: Elements of Reusable Object-Oriented Software

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.