简体   繁体   中英

How to make custom form control in c#

有一天,我意识到自己想在Visual Studio中做某事,如果我可以让表单控件替我做,那分配起来会更容易,除非我不知道该怎么做,我想要表单控件拥有网格,每个正方形都有其自己的color属性,如果有人知道如何制作表单控件,或者甚至更好地知道如何制作类似我刚才描述的内容,我会很高兴的:D

1) Inside your project: Solution Explorer --> Right Click the .csproj --> Add UserControl

2) Drag and drop gridBox or any control you want into your custom control.

3) Check the ToolBox , your custom control should be located at the very first selection

This MSDN article is a basic step by step outline of how you can write a customer control. Unfortunatly MS has not figured out how to do avoid link rot -- so you may need to search creating to find this if you come in the future. 来找到它。

You are usually best servered by subclassing an existing control and customizing it.

You might also find some of the freely available winform control projects a gold-mine of useful info if you get serious about this.

However, it sounds likely what you should consider doing is creating a "User Control", this is usually simpler for a composite of few existing controls. This article on the types of controls for winforms may be a useful overview for you.

Beyond that you really should use S/O if you are trying to resolve a specific problem you are having when you are coding. Google is a more appropriate tool for finding tutorials, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM