1


In ErrorProvider control we can use SetIconPadding(); in order to set number of pixels to add between the icon and the control.

In this way we can move icon horizontally.
How to do the same but in vertical?

I don't know how to extend or override icon positioning.

PS. SetIconAlignment() in some situation is not enough. I simply must set custom localization of icon.

4

1 回答 1

6

不幸的是,他们不是简单的方法来做到这一点。

通过使用该函数SetIconPadding(),您可以仅以水平方式定义图标和控件之间的空间,但也允许使用负值。

通过调用SetIconAlignment(),您只能将其放在控件的左侧或右侧,但不能放在控件的上方或下方。

让它工作的一个技巧是在你需要errorProvider的控件周围放置一个面板,并使其更高和/或更低。现在,您可以在此容器控件上设置提供程序,而不是直接在该控件上设置提供程序,并通过为填充应用负值,您可以将闪烁的图标移动到您喜欢的控件上方或下方。

这是某种hackish,但我认为他们没有其他方法可以做到这一点。

    +--Panel----------------------+
    |               !             |
    |     +------------------+    |
    |     | ControlWithError |    |
    |     +------------------+    |
    |                             |
    +-----------------------------+

如上所见,设置ErrorProvider不在控件上。将其设置到面板并设置为IconAlignment某个负值(例如-50),您的图标在您想要的控件上方闪烁。TopLeftIconPadding

于 2011-08-24T08:28:25.190 回答