刚才试了一下可以把Button的边框变色,但是TEXTBOX 控件的还没有实现,你看看下面的代码吧,或许对你有用,有两个属性property,关于property上面的定制标签Attribute我没有加,你可以自己加入:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace TianTextBox
{
public class TianButton : System.Windows.Forms.Button
{
private int rectWidth = 2;
public int RectWidth
{
get
{
return rectWidth;
}
set
{
rectWidth = (value < 0) ? 2 : value;
}
}
private Color rectColor = Color.Red;
public Color RectColor
{
get
{
return rectColor;
}
set
{
rectColor = ( value.Equals(null) ) ? Color.Red : value;
}
}
public TianButton()
{
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint (e);
Graphics G = e.Graphics;
Pen P = new Pen( rectColor, rectWidth);
G.DrawRectangle( P, 0, 0, this.Width, this.Height);
}
}
}