斜体字符的底部在textBox中截止

问题描述 投票:0回答:2

我有一个TableLayoutPanel,其中TableLayoutPanels为行。每个内部tableLayoutPanel都有两行。第二行是textBox,显示斜体样式的URL。然而,网址的高度被截断,像'g'这样的字符会丢失一些像素,而'_'则根本没有显示。

所以我试图改变textBox的高度 - 没有变化 - 试图改变内部tableLayoutPanel的行大小 - 没有变化 - 试图改变内部tableLayoutPanel大小本身 - 没有变化......

具有讽刺意味的是,在同一行中有另一个带有斜体文本的标签,它被绑定到每个锚的行的底部,但即使我在textBox上使用了一个锚,它仍然是截止的。

相关的textBox代码:

textBox2.Font = new System.Drawing.Font("Arial", 9.75F, 
    System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, 
    ((byte)(0)));
textBox2.Location = new System.Drawing.Point(3, 21);
textBox2.Size = new System.Drawing.Size(454, 23);

内部tlp代码:

tableLayoutPanel2.RowStyles.Add(new 
    System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 
    80F));
tableLayoutPanel2.RowStyles.Add(new 
    System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 
    27F));
tableLayoutPanel2.Size = new System.Drawing.Size(607, 44);

是否有可能显示斜体下划线:(原来是8OG8vit_-Wg)

"8OG8vit_-Wg" cutoff

编辑:将文本框放在它的外部组框和主窗体上。

System.Windows.Forms.TextBox textBox2 = new System.Windows.Forms.TextBox();
textBox2.BorderStyle = System.Windows.Forms.BorderStyle.None;
textBox2.Cursor = System.Windows.Forms.Cursors.IBeam;
textBox2.Font = new System.Drawing.Font("Arial", 9.75F, 
    System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, 
    ((byte)(0)));
textBox2.Location = new System.Drawing.Point(100, 290);
textBox2.Name = "textBox2";
textBox2.ReadOnly = true;
textBox2.Size = new System.Drawing.Size(454, 15);
textBox2.Text = "8OG8vit_-Wg";
textBox2.BackColor = System.Drawing.Color.Coral;
groupBox1.Controls.Add(textBox2); // this.Controls.Add(textBox2); 

结果如下:groupboxmainform

c# winforms textbox tablelayoutpanel
2个回答
3
投票

我不禁称这是一个错误。

TextBox.Multiline = falseBorderStyle.None的组合似乎使winforms超过客户规模减少,并将切断下降和下划线。

解决方法是放弃其中一个;为了你想要的外观简单地使TextBox.Multiline = true和所有应该是...:

enter image description here


1
投票
© www.soinside.com 2019 - 2024. All rights reserved.