C#:WinForms 中奇怪的渲染

发布于 2024-10-08 04:59:48 字数 193 浏览 0 评论 0原文

alt text

由于某种原因,“日期自”和“日期至”的标签在其底部边缘呈现奇怪的效果。查看日期选择器如何因此而无法正确呈现。

有谁知道为什么会发生这种情况?仅当我从可执行文件启动应用程序时才会发生这种情况。在 IDE 中不会发生这种情况。

alt text

For some reason the labels for "Date From" and "Date To" are rendering strangely on their bottom edges. See how the datepickers are not rendered correctly because of this.

Anyone know why this is occurring? It only occurs when I start the app from the exectuable. It doesn't happen in the IDE.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

起风了 2024-10-15 04:59:48

看起来 Label 控件的边界正在溢出到 DateTimePicker 控件中。即使 WinForms 控件具有透明背景,也不能保证它与同一容器中的其他控件能够很好地配合。尝试减少标签上的边距/填充,或选择两个 DateTimePicker 控件并使用“置于前面”选项。

It looks like the bounds of the Label controls are spilling over into the DateTimePicker controls. Even when a WinForms control has a transparent background, it is not guaranteed to play nice with other controls in the same container. Try reducing the margins/padding on the labels or select both DateTimePicker controls and use the "bring to front" option.

<逆流佳人身旁 2024-10-15 04:59:48

它们的背景色与表单的背景色相匹配。

有多种方法可以解决此问题:

  • 右键单击​​标签并选择“发送到后面”
  • 右键单击​​另一个控件并选择“置于前面”
  • 确保设置了标签的 AutoSize 属性为 true 并将其向上移动一点,直到不显示
  • 确保标签的 Padding 属性为 0, 0, 0, 0(每个子属性为零)

They have a backcolor that matches the form's backcolor.

There are multiple ways to solve this:

  • Right-click on the label and choose "Send to Back"
  • Right-click on the other control and choose "Bring to Front"
  • Make sure the label's AutoSize property is set to true and move it up a little until it doesn't show
  • Make sure the label's Padding property is 0, 0, 0, 0 (zero for each subproperty)
情独悲 2024-10-15 04:59:48

在 VS 中,当使用鼠标操作控件时,很容易意外更改控件的大小和位置。您可能只需要移动/调整它们的大小,这样它们就不会重叠。尝试使用箭头键移动或明确给出数字位置和大小值。

It's frighteningly easy in VS to accidentally change the size and location of controls when manipulating them with the mouse. You may just have to move/re-size them so they don't overlap. Try moving with the arrow keys or explicitly giving them numeric position and size values.

傾旎 2024-10-15 04:59:48

正如 mickeyf 所指出的,很容易意外地移动控件或调整控件的大小。

为了减少发生这种情况的可能性,VS 允许您锁定控件。如果右键单击表单上的任意位置,然后选择“锁定控件”,这将锁定表单上的每个控件。我一直觉得这个太严厉了,所以很少使用它。

但直到最近我才发现,每个控件都有一个可以单独设置的“锁定”属性。我发现这更方便 - 您只需锁定容易出现问题的控件即可。

例如,我有几个表单,它们的顶部有一个工具栏,另一个控件正好填充表单的其余部分。很容易意外地使该控件碰撞一个像素左右,而没有意识到这一点。现在我只需锁定这些控件,这比锁定所有内容方便得多。

As mickeyf notes, it's very easy to accidentally move or resize a control.

To reduce the likelihood of this happening, VS allows you to lock controls. If you right click anywhere on the form, and select "Lock Controls", this will lock every control on the form. I always found this to be too draconian, and rarely used it.

But what I somehow missed until very recently, each control has a "Locked" property that can be set individually. I find this much more convenient - you just lock the controls that tend to be problematic.

For example, I have several forms that have a toolbar at the top, and another control that exactly fills the rest of the form. It's very easy to accidentally bump this control by a pixel or so, and not realize it. Now I just lock those controls, which is way more convenient than locking everything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文