C#中的不规则形状用户控件 [英] Irregular Shape User Control in C#

查看:71
本文介绍了C#中的不规则形状用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

专家!你能教我如何在C#中制作一个不规则形状的用户控件吗?

我有一个绘制半圆形矩形的代码,我希望我的用户控件形状像我的半圆形矩形......

请帮帮我,代码片段会做......或者其他什么..

谢谢! :)



PS:我第一次在这里发一个问题.. :)

如果你有任何问题/反应如何我在这里询问,请告诉我..再次感谢! :)

Guys! Can you teach me how to make an irregular shape user control in C#?
I have a code that draws a semi circular rectangle and I want my user control to be shape like my semi circular rectangle...
Please help me, a code snippet will do... or anything..
Thanks! :)

PS: my first time to post a question in here.. :)
If you have any problems/reactions on how I questioned in here, please tell me.. thanks again! :)

推荐答案

从相应的基类派生你的控件,例如

public class MyButton:System.Windows .Forms.Button

并覆盖OnPaint方法:

protected override void OnPaint(PaintEventArgs e)

参见eg AquaButton:带有Mac OS X外观的示例自定义按钮控件 [ ^ ]

如果你使用WPF,你可以使用现有控件的样式。
Derive your control from the respective base class, e.g.
public class MyButton : System.Windows.Forms.Button
and override the OnPaint method:
protected override void OnPaint(PaintEventArgs e)
See e.g. AquaButton: A sample custom button control with a Mac OS X look[^]
If you use WPF, you can use styles for existing controls.


看看:

http://www.youtube.com/watch?v=K_JzL4kzCoE [ ^ ]


这篇关于C#中的不规则形状用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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