显示propertygrid中bool值的复选框 [英] showing checkbox for the bool values in the propertygrid
问题描述
我有一个属性网格,其中我有一些bool值,其中一个下拉列表或组合框来自defult。
I have a propertygrid in which i have some bool values for which a dropdownlist or combobox is coming by defult.
我的要求是在属性网格中为bool值显示复选框而不是下拉列表。
但主要的问题是我能够在属性网格中获得bool值的复选框,但是下拉列表仍然会出现,这会产生问题。
But the main problem is that i am able to get check box for bool values in the property grid but dropdownlist is still coming which is creating problem.
如果我设置为true,则下拉列表中的true和false都会被检查,反之亦然。
As if i am setting true as checked both true and false in the dropdownlist are coming as checked and vice versa.
是否有任何可能的方法只显示复选框而不是属性栏中的bool值的下拉列表。
推荐答案
这有点作弊,因为很遗憾无法在值区域中托管控件PropertyGrid。但是,如果我们有正确的UITypeEditor,则可以在该区域中绘制。
UITypeEditor有几个方法 GetPaintValueSupported 和 PaintValue ,使您可以绘制值的预览。这是图像的缩略图在属性网格中的图像数据旁边显示的方式。通过创建编辑器并将其分配给布尔值,您可以显示一个复选框,只要值设置为true,就会显示复选标记。
UITypeEditor has a couple of methods GetPaintValueSupported and PaintValue that enable you to draw a preview of the value. This is how the thumbnail of images is displayed next to image data in the property grid. By creating an editor and assigning it to your boolean value you can display a checkbox which shows a check-mark whenever the value is set to true.
以下清单说明了这种技术。
这篇关于显示propertygrid中bool值的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!