English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a TextBox(Multiline) problem in C#.
For example, if i type "apple" (in lower case), Expected ouput is "APPLE". But the outcome is, "ELPPA".
The Cursor is not working as per our expectation.
Cursor moves to left-sided end when we type.

Purpose of the code: "To convert the (input) text typed in to Upper Case by using a method. And strictly without using the CharacterCasing property of TextBox to convert case".
Pls try to give me a good solution, iff u hav any solution.
I'm facing problem with the code below.
Pls solve it ASAP
Thanx in Advance.

Code:

public String ToCaps(String str)

{
return str.ToUpper();
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
textBox1.Text = ToCaps( textBox1.Text);
}
catch (Exception ex)
{
Environment.Exit(1);
}
}

2006-08-30 20:47:10 · 4 answers · asked by kalaiguna 2 in Computers & Internet Programming & Design

4 answers

better ask a real computer programmer about this case...

2006-08-30 20:54:02 · answer #1 · answered by i crave yours 5 · 0 2

it is because, when you this:
textBox1.Text = ToCaps( textBox1.Text);

The Event textBox1_TextChanged is again fired.

Try using KeyPress event:
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{

if (e.KeyChar >= 'a' || e.KeyChar <= 'z')
e.KeyChar = char.ToUpper(e.KeyChar);


}
You might require to add some more validation.

2006-08-30 21:59:27 · answer #2 · answered by mayur kotlikar 2 · 0 0

Nope.

2006-08-30 20:52:33 · answer #3 · answered by NONAME 1 · 0 1

hi did u have right to show the pix

2006-09-07 19:17:09 · answer #4 · answered by me 2 · 0 1

fedest.com, questions and answers