如何创建自定义单选按钮C#Compact Framework 3.5 [英] How to create custom radiobutton c# compact framework 3.5
本文介绍了如何创建自定义单选按钮C#Compact Framework 3.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一些现成的代码,但是失败了.如果有人解释创建过程,对我来说就足够了.
I tried to find some ready code, but I failed. it would be enough for me, if someone explain the process of creatiojn. Is radiobutton merged two controls or just a modified label?
推荐答案
WinForms单选按钮是Windows的标准控件,因此很难对它们进行小的扩展.
单选按钮,按钮和文本一起是一个控件.如果要更改其外观,可以覆盖OnPaint,但需要同时绘制两个部分.
我在此处找到了一个示例[ ^ ].
WinForms radio buttons are standard Windows controls, and therefore it''s quite difficult to perform small extensions on them.
A radio button, button and text together, is one control. If you want to change its appearance, you can override OnPaint, but you need to draw both parts.
I found an example here[^].
由于Bob正确指出的原因,正确的解决方案如下:
创建您自己的单选按钮控件,这是一个完全自定义的按钮控件.从System.Windows.Forms.Control
派生您的类,根据状态等覆盖OnPaint
来呈现其外观.在状态更改或影响控件外观的任何其他属性上使用System.Windows.Forms.Control.Invalidate
.
使用System.Windows.Forms
,这是非常简单的任务.
—SA
By the reasons Bob correctly pointed out, right solution would be the following:
Create your own radio button control, a completely custom one. Derive your class right fromSystem.Windows.Forms.Control
, overrideOnPaint
to render its appearance depending on states, etc. UseSystem.Windows.Forms.Control.Invalidate
on the change of state or any other properties affecting control appearance.
WithSystem.Windows.Forms
, this is pretty simple task.
—SA
这篇关于如何创建自定义单选按钮C#Compact Framework 3.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文