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);
}
}
I have a TextBox(Multiline) problem in C#. do u have any solution?
better ask a real computer programmer about this case...
Reply:Nope.
Reply: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 %26gt;= 'a' || e.KeyChar %26lt;= 'z')
e.KeyChar = char.ToUpper(e.KeyChar);
}
You might require to add some more validation.
Reply:hi did u have right to show the pix
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment