对照与用户控件中的WinForms? [英] Control vs UserControl in WinForms?

查看:192
本文介绍了对照与用户控件中的WinForms?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控件和.NET的WinForms一个用户控件之间的区别是什么?我想创建一个自定义的控制,但应该从我继承?我一直使用的控制,在过去没有任何问题,但创建自定义控制的推荐的方式?

What is the difference between a Control and a UserControl in .NET WinForms? I want to create a custom control, but which one should I inherit from? I've always used Control in the past without any issues, but is the "recommended" way of creating a custom control?

推荐答案

下面是关于这个问题的好文章。 用户控件

Here is a good article about this question. user controls

然而,在短期

一个控制则继承或完全自定义的。你写和处理很多自己的事件。你甚至可以控制何时以及如何控制绘制通使用GDI + 图。

A Control is either inherited or completely custom. You write and handle many of the events yourself. You can even control how and when the control is drawn thru the use of GDI+ drawing.

一个用户控件是放置在一起以一定的方式被使用的控制集合。例如,你可以将一个包含文本框的,复选框,等等。当你必须把同组的控制上/多种形式或制表符这是非常有用的一个分组框。注意:您可以编写一些自定义事件和绘图的用户控件也

A UserControl is a collection of controls placed together to be used in a certain way. For example you can place a GroupBox that contains Textbox’s, Checkboxes, etc. This is useful when you have to place the same group of controls on/in multiple forms or tabs. Note: you can write some custom events and drawing for UserControls also.

这篇关于对照与用户控件中的WinForms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆