Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear All We had developed a hr application(winform) which consist of almost 98 forms .And its in testing in our organisation .
But the problem now is the management wants all the data inputs to be in UPPERCASE .we had not set any character casing in any of our controls and now its almost very hazardous to change the character casing to all controls

Can anyone suggest any idea to do restrict the input to uppercase only ?.I had tried some thing at the Program.cs file.but it seems not working

Also tried to overide textbox.textchanged event it seems to be a foolish idea any more ideas please considering us as new bie in development
Posted

You can call this method at the time of form load.

C#
private void UpparCasingTextBoxes() 
 { 
     Action func = null; 
 
     func = (controls) => 
         { 
             foreach (Control control in controls) 
                 if (control is TextBox) 
                     (control as TextBox).CharacterCasing = CharacterCasing.Uppar 
                 else 
                     func(control.Controls); 
         }; 
 
     func(Controls); 
 }
 
Share this answer
 
textbox has property CharacterCasing set it's value Upper

Happy Coding!
:)
 
Share this answer
 
Comments
SREENATH GANGA 16-Oct-12 4:30am    
Its 100s of controlssover there .........
Aarti Meswania 16-Oct-12 4:36am    
will need manual effort
if you have use components & user-control then it can be easy
Aarti Meswania 16-Oct-12 4:54am    
create component that inherits form suppose this component is AForm
and now override on load event call solution-2's method

and now inherit AForm in all 98 forms
This might be an out of box idea.....
The default font for windows form is "Microsoft Sans Serif, 8.25pt"
its child inherit same font.
so you can replace the original "Microsoft Sans Serif" font by a font which has only uppercase. eg:-Trajan Pro [character remain uppercased in both lower and uppercase,only the size differs]
change the name of the new font by "Microsoft Sans Serif"
 
Share this answer
 
Comments
MT_ 16-Oct-12 5:23am    
really out of the box !! Good one but.
SREENATH GANGA 25-Oct-12 5:22am    
wow great idea dear...let me try

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