Winforms 文本框保证金? space 区别
Winforms TextBox margin? space difference
我观察到 TextBox 的边距设置对控件没有明显影响(即使我希望如此)。但是,我使用 TextBox 编写了一个简单的测试程序,它有不同的边距!我仔细比较了我的两个程序,它们之间没有相关差异,但一个从边缘到 TextBox 中输入的第一个字符只有两个像素,另一个有七个像素到相同的字符!对这种差异有解释吗?
TextBox 的设计器设置在两个程序中是相同的:
this.textBox1.AcceptsReturn = true;
this.textBox1.AcceptsTab = true;
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.HideSelection = false;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Margin = new System.Windows.Forms.Padding(0);
this.textBox1.MaxLength = 0;
this.textBox1.Multiline = true;
this.txtBody.TabIndex = 0;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
除了“名称”、“大小”和事件处理程序之外,这两个 TextBox 都没有其他设置。
示例屏幕截图:
@Hans 你的问题和提示得到了回报。进一步和更仔细的检查表明程序环境默认为不同的字体。当我指定字体时,边距是一样的。谢谢你帮我找到答案。
我观察到 TextBox 的边距设置对控件没有明显影响(即使我希望如此)。但是,我使用 TextBox 编写了一个简单的测试程序,它有不同的边距!我仔细比较了我的两个程序,它们之间没有相关差异,但一个从边缘到 TextBox 中输入的第一个字符只有两个像素,另一个有七个像素到相同的字符!对这种差异有解释吗?
TextBox 的设计器设置在两个程序中是相同的:
this.textBox1.AcceptsReturn = true;
this.textBox1.AcceptsTab = true;
this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.textBox1.HideSelection = false;
this.textBox1.Location = new System.Drawing.Point(0, 0);
this.textBox1.Margin = new System.Windows.Forms.Padding(0);
this.textBox1.MaxLength = 0;
this.textBox1.Multiline = true;
this.txtBody.TabIndex = 0;
this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
除了“名称”、“大小”和事件处理程序之外,这两个 TextBox 都没有其他设置。
示例屏幕截图:
@Hans 你的问题和提示得到了回报。进一步和更仔细的检查表明程序环境默认为不同的字体。当我指定字体时,边距是一样的。谢谢你帮我找到答案。