GDI和自定义控件的创建 [英] GDI and custom control creation

查看:112
本文介绍了GDI和自定义控件的创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何使用自定义控件来创建自己的控件(工具),例如在vs.net工具箱中.如果我们创建一个自定义控件,是否可以使用GDI创建一个自定义控件.有人可以帮我如何通过GDI创建我们自己的自定义控件.我已经读过有关在cuatom控件中创建按钮的信息.我想知道的是如何创建一个复杂的控件,如工具栏,菜单,滑块等.我将在此先谢谢您.请帮我.有人可以针对我的疑问发布文章和源代码或演示项目.谢谢...

How do we use custom controls to create our own controls(tools) like in the vs.net toolbox. If we create a custom control, Can we create a customcontrol by using GDI. Can somebody please help me on how to create our own custom controls by GDI. I''ve already read about creating buttons in cuatom controls.All I want to know is how to create a complex control like toolstrips,menubars,sliders etc. I''ll Thank you in advance. Just please Help me with that. Can somebody post an article and source code or demo project on my doubts above.Thank You...

推荐答案

创建自己的控件所需的最低限度是一个类继承自System.Windows.Forms.Control类.有了它后,如果您构建项目,则该项目应显示在工具箱中.如果要在其他项目中使用它,则将其编译为类库DLL,然后在VS中,右键单击工具箱"并选择选择项目",然后浏览到您的DLL文件

您的课程将有一个Paint事件,您可以使用GDI +绘制任何事件;如果需要,您可以通过P/Invoke使用GDI.

任何公共属性都将显示在表单设计器的属性网格中.

希望对您有帮助
The minimum you need to create your own controls is a class that inherits from the System.Windows.Forms.Control class. Once you have this, if you build the project, it should appear in the toolbox. If you want to use it in other projects, compile it as a Class Library DLL, then in VS, right click in the Toolbox and select Choose Items, then Browse to your DLL file

Your class will have a Paint event, which you can use to draw whatever you need using GDI+; You can use GDI through P/Invoke if you want though.

Any public properties will show up in the property grid on the form designer.

Hope this helps


这篇关于GDI和自定义控件的创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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