-2

How to change character casing in TextBox? I need that 1 line character been Upper and second line character benn Lower

isv.CharacterCasing = CharacterCasing.Upper;
isv.Text = "Upper"

isv.CharacterCasing = CharacterCasing.Lower;
isv.Text = "Lower"
John Arlen
  • 6,539
  • 2
  • 33
  • 42
Wizard
  • 10,985
  • 38
  • 91
  • 165
  • 5
    Your question is quite hard to understand. Could you give a specific example to make it clear? Do you want a multiline text box where characters entered on the first line are automatically uppercased, and characters on the second line are automatically lowercased? – Mark Byers Mar 25 '12 at 18:57
  • Which TextBox (Win, WPF, ASP) ? – H H Mar 25 '12 at 18:58

3 Answers3

1

You can use TextBox.Lines property I guess.

something like:

        private void button1_Click(object sender, EventArgs e)
    {
        string result = string.Empty;

        result += textBox1.Lines[0].ToUpper() + Environment.NewLine;
        result += textBox1.Lines[1].ToLower();

        textBox1.Text = result;
    }
Dumbo
  • 13,555
  • 54
  • 184
  • 288
1

As Mark said, it's difficult to understand exactly what you need, but I think it's something like

string[] lines = isv.Text.Split('\n');
string finalText = string.Empty;
for (int i = 0; i < lines.length; i++)
    finalText += i%2==0 ? lines[i].ToUpper() : lines[i].ToLower() +  + Environment.NewLine;
isv.Text = finalText;

Keep in mind I wrote the code without the compiler :)

Alejandro B.
  • 4,807
  • 2
  • 33
  • 61
0
isv.Text = isv.Text.Split(Environment.NewLine)[0].ToUpper() + isv.Text.Split(Environment.NewLine)[1].ToLower();