C# PropertyGrid PaintValue问题:如何删除(并在外部绘制)标准矩形?
这可能是一个直截了当的问题,尽管我还没有找到一个简单的解决方案: 我实现了我的自定义UITypeEditor,唯一的目的是向布尔添加一个PaintValue。为了便于讨论,我们假设PaintValue将绘制选中或未选中的单选按钮 问题1: 现在,问题来了:在所有绘制代码完成后,PaintValue似乎会自动插入一个20x13px的矩形。当然,黑色矩形内的单选按钮很难看。我可以很容易地指示或覆盖此矩形不涂漆吗 问题2: 在这方面,是否有可能在propertygrid的原生外观上进行绘制——也就是说,我是否可以绘制一些东西来掩盖垂直分隔两个网格单元的黑线部分?这样做的目的是表明两个值是链接的,例如受约束的宽度/高度与纵横比C# PropertyGrid PaintValue问题:如何删除(并在外部绘制)标准矩形?,c#,.net,propertygrid,paint,uitypeeditor,C#,.net,Propertygrid,Paint,Uitypeeditor,这可能是一个直截了当的问题,尽管我还没有找到一个简单的解决方案: 我实现了我的自定义UITypeEditor,唯一的目的是向布尔添加一个PaintValue。为了便于讨论,我们假设PaintValue将绘制选中或未选中的单选按钮 问题1: 现在,问题来了:在所有绘制代码完成后,PaintValue似乎会自动插入一个20x13px的矩形。当然,黑色矩形内的单选按钮很难看。我可以很容易地指示或覆盖此矩形不涂漆吗 问题2: 在这方面,是否有可能在propertygrid的原生外观上进行绘制——也就是说
非常感谢您的回答。我不知道这幅画,但在第2点-可能通过IPropertyValueUIService添加一个glyph-有一个例子。我不知道这幅画,但是在第2点上——可能通过IPropertyValueUIService添加图示符——有一个例子。您可以使用以下代码删除矩形,但不能在其外部绘制。嗯,你可以画画,但是PropertyGrid稍后会在上面画画,所以它没有多大意义
public override void PaintValue(PaintValueEventArgs e)
{
// remove the lines (you cannot draw on these lines anymore)
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, 1));
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.X, e.Bounds.Y, 1, e.Bounds.Height));
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.Width, e.Bounds.Y, 1, e.Bounds.Height));
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.X, e.Bounds.Height, e.Bounds.Width, 1));
// now draw your own image - it will be shown without the box
e.Graphics.DrawImage(myImage, e.Bounds);
}
可以使用以下代码删除矩形,但不能在其外部绘制。嗯,你可以画画,但是PropertyGrid稍后会在上面画画,所以它没有多大意义
public override void PaintValue(PaintValueEventArgs e)
{
// remove the lines (you cannot draw on these lines anymore)
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, 1));
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.X, e.Bounds.Y, 1, e.Bounds.Height));
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.Width, e.Bounds.Y, 1, e.Bounds.Height));
e.Graphics.ExcludeClip(
new Rectangle(e.Bounds.X, e.Bounds.Height, e.Bounds.Width, 1));
// now draw your own image - it will be shown without the box
e.Graphics.DrawImage(myImage, e.Bounds);
}
有趣的链接。不过,我希望得到一个更简单、更清晰的答案。它不是应用程序的核心功能,所以我宁愿保持代码库的整洁,也不愿意为了画几行就用大量的东西把它弄得乱七八糟。有趣的链接。不过,我希望得到一个更简单、更清晰的答案。它不是应用程序的核心特性,所以我宁愿保持代码库的整洁,也不愿为了画几行线而用大量的东西把它弄得乱七八糟。