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"
Решение
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 :)
Другие советы
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;
}
isv.Text = isv.Text.Split(Environment.NewLine)[0].ToUpper() + isv.Text.Split(Environment.NewLine)[1].ToLower();
Не связан с StackOverflow