Resize 和 SizeChanged 事件之间的区别区别、事件、Resize、SizeChanged

由网友(一个缺爱嘀孩纸)分享简介:在 Winforms 中的 C# .Net 中,我在几乎所有组件中都发现了两个事件,Resize() 和 SizeChanged().它们之间有什么区别吗?如果两个事件相同,那为什么 C# 提供了两个不同的事件?In C# .Net in Winforms, I found two events in almost...

在 Winforms 中的 C# .Net 中,我在几乎所有组件中都发现了两个事件,Resize() 和 SizeChanged().它们之间有什么区别吗?如果两个事件相同,那为什么 C# 提供了两个不同的事件?

In C# .Net in Winforms, I found two events in almost all components, Resize() and SizeChanged(). Is there any difference between them? If both events are the same then why has C# provided two different events?

我正在用 C# 创建一个用户控件.此控件包含一个文本框.当用户更改控件的大小时,我想调整文本框的大小.我不知道应该使用哪个事件以及为什么?

I am creating a user control in C#. This control contains a text box. I want to resize the textbox when the user changes the control's size. I am confused about which event I should use and why?

推荐答案

Resize 事件发生在控件调整大小时,SizeChanged 事件发生在>尺寸属性变化.

The Resize event occurs when the control is resized, while the SizeChanged event occurs when the Size property changes.

您可以使用任何一种,因为调整大小会导致 Size 属性发生变化.但是,您应该按照 调整大小 和 SizeChanged 事件.

You could use either, as a resize will cause the Size property to change. However, you should rather use the Layout event, as recommended both in the documentation for the Resize and SizeChanged events.

阅读全文

相关推荐

最新文章