如何在TextBox中更改字符大小写?我需要1行字符为Upper和second line character benn Lower
isv.CharacterCasing = CharacterCasing.Upper;
isv.Text = "Upper"
isv.CharacterCasing = CharacterCasing.Lower;
isv.Text = "Lower"
答案 0 :(得分:1)
我猜你可以使用TextBox.Lines
属性。
类似的东西:
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;
}
答案 1 :(得分:1)
正如马克所说,很难准确理解你的需求,但我认为这就像
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;
请记住,我在没有编译器的情况下编写代码:)
答案 2 :(得分:0)
isv.Text = isv.Text.Split(Environment.NewLine)[0].ToUpper() + isv.Text.Split(Environment.NewLine)[1].ToLower();