Custom Control in c#

A

anant

Can anyone tell me how can i write on a custom control area using
keyboard.
i.e i want that custom control to work like textbox, but i m not
using (inheriting) textbox instead
i m creating my control using UserControl

thanks in advance.
 
P

Peter Duniho

Can anyone tell me how can i write on a custom control area using
keyboard.
i.e i want that custom control to work like textbox, but i m not
using (inheriting) textbox instead
i m creating my control using UserControl

UserControl is a scrollable container that is usually used for putting
other controls inside it. Unless you are specifically needing that
behavior for some reason, you should inherit Control, rather than
UserControl (I know, the name's confusing...but UserControl isn't a
general-purpose base class for custom controls).

As far as implementing a text box goes, it depends on what you want to
do. How much of the functionality that TextBox has do you want to
create? How much work are you willing to put into it? Even for an
experienced programmer, this is a good week-long project just to get all
of the various features implemented, never mind tested and debugged. If
you just want a subset, it could be a lot easier, depending on what you
actually want to do.

As for how to go about it, you'll need to override things like
OnKeyDown(), OnPaint(), etc. to handle key input and drawing the control.
Short of actually writing the control for you and showing you code, I
don't know how else to answer the question. If you're unfamiliar with
writing custom controls, I'll suggest that implementing a text box may not
be a good first effort. You might want to write a simpler custom control
first, learning each part as you go.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top