473,395 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Converting Keystrokes in upper case

In my application there is need for only upper case chars..
Currently I am making entry to upper case when user leaves focus of the
text control.
I want to do some modification here...When user enters any char in
small case...during that entry it should convert in upper case...
It is very easy in VB6..In VB6 you just need to convert the Ascii value
to char ---> then to Ucase ---> then char to Ascii again...this can be
done in keypress event...

I am facing problem in C# how to do this ?

Is there anybody to help..................

please write solution to ma*******@rediffmail.com
Thanks in advance....
Regards
Manish

Nov 16 '05 #1
6 12524
What you'll want to do is handle the KeyPress event, and handle the
upper case code there. That will result in changing every time a key is
pressed.

Lowell


Manish wrote:
In my application there is need for only upper case chars..
Currently I am making entry to upper case when user leaves focus of the
text control.
I want to do some modification here...When user enters any char in
small case...during that entry it should convert in upper case...
It is very easy in VB6..In VB6 you just need to convert the Ascii value
to char ---> then to Ucase ---> then char to Ascii again...this can be
done in keypress event...

I am facing problem in C# how to do this ?

Is there anybody to help..................

please write solution to ma*******@rediffmail.com
Thanks in advance....
Regards
Manish

Nov 16 '05 #2
Actually I did in keypress event in c#..
we get actual key char from e.KeyChar..This is the readonly property..If
I convert any keyboard input in ucase..how do I assign to it again?

If I assgin to txtBox.text = e.KeyChar.ToString().ToUpper();
My control goes to the start of the text box when I type any char in
control....

If anybody knows solution to this problem please answer....

Thanx in advance

Manish
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #3
Hi Manish,

Does this do what you need?

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
int start = this.textBox1.SelectionStart;
this.textBox1.Text = this.textBox1.Text.ToUpper();
this.textBox1.SelectionStart = start;
}

--Liam.

"Manish Khobragade" <ma*******@rediffmail.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
Actually I did in keypress event in c#..
we get actual key char from e.KeyChar..This is the readonly property..If
I convert any keyboard input in ucase..how do I assign to it again?

If I assgin to txtBox.text = e.KeyChar.ToString().ToUpper();
My control goes to the start of the text box when I type any char in
control....

If anybody knows solution to this problem please answer....

Thanx in advance

Manish
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4
I think the simplest way is to set the CharacterCasing property,
MyTextBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
and then it all happens automatically.

Chris Jobson
"Manish" <ma*******@rediffmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
In my application there is need for only upper case chars..
Currently I am making entry to upper case when user leaves focus of the
text control.
I want to do some modification here...When user enters any char in
small case...during that entry it should convert in upper case...
It is very easy in VB6..In VB6 you just need to convert the Ascii value
to char ---> then to Ucase ---> then char to Ascii again...this can be
done in keypress event...

I am facing problem in C# how to do this ?

Is there anybody to help..................

please write solution to ma*******@rediffmail.com
Thanks in advance....
Regards
Manish

Nov 16 '05 #5
Couldn't you simply set the Textbox's CharacterCasing property to
"CharacterCasing.Upper"

See
http://msdn.microsoft.com/library/de...asingtopic.asp

Shariq Khan
sh****@shariqkhan.com
"Liam McNamara" <re***@newsgroup.net> wrote in message
news:6i**************@news-srv1.fmr.com...
Hi Manish,

Does this do what you need?

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
int start = this.textBox1.SelectionStart;
this.textBox1.Text = this.textBox1.Text.ToUpper();
this.textBox1.SelectionStart = start;
}

--Liam.

"Manish Khobragade" <ma*******@rediffmail.com> wrote in message
news:us**************@tk2msftngp13.phx.gbl...
Actually I did in keypress event in c#..
we get actual key char from e.KeyChar..This is the readonly property..If
I convert any keyboard input in ucase..how do I assign to it again?

If I assgin to txtBox.text = e.KeyChar.ToString().ToUpper();
My control goes to the start of the text box when I type any char in
control....

If anybody knows solution to this problem please answer....

Thanx in advance

Manish
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #6
The CharacterCasing property is the easiest way to achieve what you
want this time.

For some other time when you have to do more sophisticated processing
than just upper casing characters, the answer is that you don't
_change_ the character in e.KeyChar. Instead, you "swallow up" the
typed character and use SendKeys.Send() to send a different keystroke
to the application.

Props to Claes Bergefal who taught me that one.

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ToddT | last post by:
i'm trying to convert names to their proper case (e.g. "todd" -> "Todd") using the following rountine: Private Function ConvertToProperCase(ByVal stringValue As String) As String Dim ci ...
2
by: kevin | last post by:
Hello, we've an Oracle transition in the pipeline and want to convert all our database objects to upper case. Any one got a script or technique (other than manual) to do it? Many thanks, Kevin.
10
by: jose.jeria | last post by:
I use the following to convert uppercase to lowercase: translate($queryString, 'ABCDE...', 'abcde...') But how can i convert the case for umlauts? öåä etc
4
by: programmerforhire | last post by:
Hello all, Is there a way to setup an ms-access table so that when I enter text in the 'datasheet' mode, it will automatically be converted tp upper case. Or must I use a Form for this? rex
3
by: Brian Conway | last post by:
How do I convert a field that is filled in to uppercase within the C3 code? I see the ToUpper in there, but how do I get the text box to convert this to upper when you change focus or move to...
8
by: Brian Conway | last post by:
How do I convert a field that is filled in to uppercase within the C3 code? I see the ToUpper in there, but how do I get the text box to convert this to upper when you change focus or move to...
5
by: Nelson | last post by:
In my web form, I am converting all lower case letters to upper case when the user types the characters in the edit boxes. I am achieving that by injecting client side script (onkeyup event) for...
3
by: Phil Galey | last post by:
In VB6 you can block invalid keystrokes in the KeyPress event by setting KeyAscii = 0. How can you block invalid keystrokes in VB.NET?
1
by: nbowman | last post by:
How do you convert lower case to upper case in the entire Access database, while maintaining data that is in upper case?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.