编写与.NET属性窗口交互的RAD组件(四)__教程 |
|
日期:2007-5-20 1:27:16 人气:103 [大 中 小] |
|
|
|
{
// let the property browser know we'd like
// to do custom painting.
return true;
}
public override void PaintValue(PaintValueEventArgs pe)
{
// choose the right bitmap based on the value
string bmpName = null;
Grade g = (Grade)pe.Value;
if (g.Value > 80)
{
bmpName = "best.bmp";
}
else if (g.Value > 60)
{
bmpName = "ok.bmp";
}
else
{
bmpName = "bad.bmp";
}
// draw that bitmap onto the surface provided.
Bitmap b = new Bitmap(typeof(GradeEditor), bmpName);
pe.Graphics.DrawImage(b, pe.Bounds);
b.Dispose();
}
}
像我们上面提到的,UITypeEditor可以实现属性的下拉选择和弹出对话框选择。后面的例子会包括这样的代码。如果想知道进一步的信息的话,就要参考UITypeEditor.GetEditStyle和UITypeEditor.EditValue方法以及IWindowsFormsEditorService接口。
|
|
出处:本站原创 作者:佚名 |
|
|