四舍五入TextBox的四个角 [英] Rounding four corners of the TextBox
本文介绍了四舍五入TextBox的四个角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我怎么能圆角TextBox的四个角?
i想要这个用于Windows窗体应用
Wiht尊重太空人
Hi
how can i Rounding four corners of the TextBox?
i want this for windows form application
Wiht Respect "Spaceman"
推荐答案
在WPF中这很容易做到 - 圆形玻璃WPF按钮的样式 [ ^ ]。如果您在互联网上搜索,您还可以找到更多信息。
Windows窗体将更具挑战性。它可以通过以下方式完成 - 绕过System.Windows的角落。 Forms.Control? [ ^ ]。
This is very easy to do in WPF - A Style for Round Glassy WPF Buttons[^]. You will also find more information if you search on the internet.
Windows forms will be more challenging. It can be done though - Rounding the corners of System.Windows.Forms.Control?[^].
嗨!
我知道我有点迟了,但是对于那些仍然需要它的人来说 - >> 此视频
创建自己的继承类从文本框中应用代码...这样的事情 - >
Hi!
I know I'm a bit late, but for anyone who still needs it check -> this vid
Create your own class that inherits from Textbox and apply the code... something like this ->
using System.Windows.Forms;
using System.Drawing;
class round :TextBox
{
[System.Runtime.InteropServices.DllImport("gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect, // X-coordinate of upper-left corner or padding at start
int nTopRect,// Y-coordinate of upper-left corner or padding at the top of the textbox
int nRightRect, // X-coordinate of lower-right corner or Width of the object
int nBottomRect,// Y-coordinate of lower-right corner or Height of the object
//RADIUS, how round do you want it to be?
int nheightRect, //height of ellipse
int nweightRect //width of ellipse
);
protected override void OnCreateControl()
{
base.OnCreateControl();
this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(2,3,this.Width,this.Height,15,15)); //play with these values till you are happy
}
就是这样!
; )
That's it!
;)
覆盖按钮的绘制事件并自己绘制,也可以使用图像。
Override paint event of button and draw it yourself, you can use an image too.
这篇关于四舍五入TextBox的四个角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文