creating a custom button, keyboard

G

Guest

Hi all,
I have a question about a custom control. I'm very new to c# programming so
forgive me if the question is very basic.
I want to create some kind of a keyboard, with some buttons, such that when
the user clicks a button, that button's text will be added to a textbox. For
example, if the button's text is "A", when it's clicked - "A" will be added
to the textbox. I want to have this functionality in some forms.

I thought of creating a custom control for a single button, and implement
its click event to display the button's text property. After that, make about
15 copies of that control, each one with a different text, and position them
in the order that I want, and make another control out of the whole thing.
Then I can use this control in all of the forms where I need this keyboard.

1. Do I need to inherit the single button when building the keyboard in
order to change the text property?
2. Is it basically the right way to do it?

3. I want to write to a different textbox every time (according to the user
clicks on the textbox). I thought of using some global textbox variable
together with the textbox GotFocus event, so that whenever a GotFocus event
triggers, the global variable will be the textbox that has got focus. Can it
be done this way? How do I do this?

Thanks a lot
 
E

Emma Middlebrook

Could you not just have one user control that has all the buttons that
you want to represent the keys on it. Then you'd have a way of sending
a notification when a key has been pressed like SendKeys.

This UserControl can then be used by other forms, they would subscribe
to the event mechanism and receive notification every time a key is
pressed so that they can update their particular textbox.

Emma
 
G

Guest

Thanks for your answer, Emma
Do you mean that I only have one keyboard? This is not exactly what I want.
I want the keyboard on some forms.
However, this is not a problem once I have it.
As for building the keyboard from the button, what do you think about this
way?
 
E

Emma Middlebrook

Thanks for your answer, Emma
Do you mean that I only have one keyboard? This is not exactly what I want.
I want the keyboard on some forms.
However, this is not a problem once I have it.
As for building the keyboard from the button, what do you think about this
way?

Hi,

What I meant was to design one keyboard as a user control. Then on the
forms you'd have a way to use an instance of the keyboard. The way
we've done it is to have a special label that when you click on the
label it pops up a keyboard for the user to use. Wherever we need a
keyboard control to be available we'd put this label next to the edit
control. When the keyboard is launched, the keys that are pressed are
then displayed in the edit control next to the label.

Hope that helps,

Emma
 

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