DomainUpDown (spinner) control is cutting off the bottom pixel of displayed text
I'm using winforms and the DomainUpDown control's height is locked at 20 pixels, which results in "y"'s and other characters with descenders cut off on the bottom.
My initial thought about how to fix the problem was to change the controls height, but I couldn't do so. In the designer I only have controls to drag it's size by width. The property page immediately reverts any change to height I make. Attempts to change the value in code silently fail; no error, no exception, but no change to the value either.
In this sample form the "g" in the DomainUpDown will be cut.
public partial class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.DomainUpDown domainUpDown1 = new System.Windows.Forms.DomainUpDown(); public Form1() { this.domainUpDown1.Location = new System.Drawing.Point(16, 8); this.domainUpDown1.Size = new System.Drawing.Size(212, 20); this.domainUpDown1.Text = "why are descenders like g cut?"; this.ClientSize = new System.Drawing.Size(328, 64); this.Controls.Add(this.domainUpDown1); } }
I see the same fixed height behaviour when using DomainUpDown controls. You can adjust the size of the font that is used, which changes the height of the control to match the text. Perhaps adjusting the size of your text slightly can help with the clipping of the characters with "descenders". I see no clipping using the default 8.25pt font.
EDIT: After replicating on XP running the classic theme and with Dan's testing, the problem appears to be the thickness of the borders and padding, which cut off the g.
Setting the BorderStyle
to either FixedSingle
or None fixes the problem.
domainUpDown1.BorderStyle = BorderStyle.FixedSingle;
or
domainUpDown1.BorderStyle = BorderStyle.None;
You will need to see what looks best in your application. Oh, and setting your theme to XP (rather than classic) will work too.
链接地址: http://www.djcxy.com/p/61988.html上一篇: '用户控件'构造函数的参数在C#中