如下代码:直接继承自Control,其它代码会自动生成好。
[csharp] view plaincopyprint
[ToolboxItem(true)]
public partial class CustomClassifyLabelItem : Control
{
private Color mColorOut = ColorFromArgb(255, 137, 37);
private StringFormat format;
private Color textColor;
private Font strFormat = new Font("宋体", 9F, FontStyleRegular, GraphicsUnitPoint, ((byte)(134)));
public StringFormat Format
{
get
{
if (format == null)
{
format = new StringFormat();
formatAlignment = StringAlignmentCenter;
formatLineAlignment = StringAlignmentCenter;
formatFormatFlags = StringFormatFlagsNoWrap;
formatTrimming = StringTrimmingEllipsisCharacter;
}
return format;
}
}
public Color TextColor
{
get
{
{
textColor = ColorFromArgb(22, 95, 162);
}
return textColor;
}
}
public CustomClassifyLabelItem()
{
InitializeComponent();
thisMouseEnter += new EventHandler(UCSelectClassifyItem_MouseEnter);
thisMouseLeave += new EventHandler(UCSelectClassifyItem_MouseLeave);
}
void UCSelectClassifyItem_MouseLeave(object sender, EventArgs e)
{
strFormat = new Font("宋体", 9F, FontStyleRegular, GraphicsUnitPoint, ((byte)(134)));
Invalidate();
}
void UCSelectClassifyItem_MouseEnter(object sender, EventArgs e)
{
strFormat = new Font("宋体", 12F, FontStyleRegular, GraphicsUnitPoint, ((byte)(134)));
Invalidate();
}
protected override void OnPaint(PaintEventArgs pe)
{
baseOnPaint(pe);
Graphics graphics = peGraphics;
using (SolidBrush b = new SolidBrush(TextColor))
{
graphicsDrawString(thisText, strFormat, b, new Rectangle(0, 0, thisWidth, thisHeight), Format);
}
graphicsDispose();
}
}12
2可见
3Value
4Enabled
5Enabled
6RecordSource
7ColumnCount
8菜单级,普通
9Init
10Group by
11定义,is null
12向导
13delete all
14Updata
15投影好象不成。不过你可以用控件。我印象中,label是透明的。你做一个有立体感的放在上面,看起来象一个按钮。然后按下后就换,变成按下去的样子。
这样你的按钮想改成什么形状都可以。只是激活的范围还是方块的。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)