作物子控件在.NET的WinForms区域作物、控件、区域、NET

2023-09-04 23:22:19 作者:黒茗單裏有迩更精彩

我目前正在设计一个用户控件将包含在它的其他控件。我希望能够控制在其中他们提供的区域(类似 Graphics.SetClip )。

I am currently designing a user control which will have other controls contained within it. I would like to be able to control the region in which the they are rendered (similar to Graphics.SetClip).

在理想情况下,我想比布尔让他们呈现到离屏幕图像,然后我present为我选择的用户。不得已将放置在我的控制面板,然后使用它作为他们的父母。

Ideally I would like to beable to have them render to an off screen image which I then present to the user as I choose. The last resort would be to place a panel in my control and then use that as their parent.

推荐答案

设置的 Control.Region 子控件的属性。从文档:

Set the Control.Region property of the child controls. From the docs:

该操作系统不显示   一个窗口摆在任何部分   窗口区域之外。

The operating system does not display any portion of a window that lies outside of the window region.

请注意该地区相对于控制在其上的设置的,不是你的包含控制(不像Graphics.SetClip)。

Note the region is relative to control on which it is set, not your containing control (unlike Graphics.SetClip).