Search code examples
c#winformstextboxcasing

Multiple character casing in same TextBox


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"

Solution

  • 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 :)