Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, there
I make one sample KeyBoard Layout for my WinForm application.
Having same button which our normal keyboard has.

My question is...
I am showing only CAPS letters on button.
How I can change all btn Text if I press and hold SHIFT key?[I mean to say change CAPS to LOWER-CASE]
Posted
Comments
[no name] 17-Jul-15 15:35pm    
The simplest method would be to iterate through your buttons and change the text to lower case. What exactly is the problem?
Sergey Alexandrovich Kryukov 18-Jul-15 1:09am    
Even this trivial ugly question deserves some advice. Please see Solution 1. There are some delicate moments...
—SA
Sergey Alexandrovich Kryukov 18-Jul-15 0:55am    
What have you tried so far?
—SA

1 solution

Wes Aday, essentially, already answered the question in his comment to it.

It's hard to believe that you were unable to find all what you need:
https://msdn.microsoft.com/en-us/library/ms158234(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/hhef7hhe(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/system.char.toupper(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/ewdd6aed(v=vs.110).aspx[^],
https://msdn.microsoft.com/en-us/library/e78f86at(v=vs.110).aspx[^] (see also other ToUpper and ToLower functions, those taking cultures into account).

Basically, that's all. But if you want to create a real virtual keyboard, please see my detailed recent answer: How to fire a Key Press event of a Key on button click in WPF[^].

Now, about the traversing the set of buttons. Here is my main advice: don't use the designer; it will be too much stupid manual work. Instead, add all keys (buttons) programmatically, in code, calculating their positions from some data model describing the keyboard layout. For example, you can produce the list of buttons each representing a key row, and a list of those lists representing the whole keyboard. And then you can traverse both lists in code, in two nesting foreach loops. Or you can create one single list or array (maybe using the list's ToArray method) representing all the keys (buttons). And, in the loop, do the changes you want.

If you need realistic keyboard layouts built in the same way as traditional keyboards, you will need the combination if shift and CAPS states of the keyboard. You can keep all the information on all states in each of the buttons, using, say, the button's Tag property.

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900