c#textbox行间距
时间: 2023-11-17 07:08:08 浏览: 189
以下是设置C# TextBox行间距的代码示例:
```csharp
// 设置行间距为1.5倍行高
textBox1.Font = new Font(textBox1.Font.FontFamily, textBox1.Font.Size);
textBox1.Multiline = true;
textBox1.ScrollBars = ScrollBars.None;
textBox1.BorderStyle = BorderStyle.None;
textBox1.BackColor = Color.White;
textBox1.Text = "这是一段文本";
textBox1.TextChanged += new EventHandler(textBox1_TextChanged);
private void textBox1_TextChanged(object sender, EventArgs e)
{
// 设置行间距为1.5倍行高
textBox1.Font = new Font(textBox1.Font.FontFamily, textBox1.Font.Size);
textBox1.SelectionStart = textBox1.Text.Length;
textBox1.SelectionLength = 0;
textBox1.SelectionFont = new Font(textBox1.Font.FontFamily, textBox1.Font.Size, FontStyle.Regular);
textBox1.SelectionBackColor = Color.White;
textBox1.SelectionLength = 0;
textBox1.SelectionStart = textBox1.Text.Length;
}
```
阅读全文