[Lazarus] How to hide class names in a property grid?

Gabor Boros gaborboros at yahoo.com
Thu Nov 12 16:13:48 CET 2015


2015.11.12. 11:33 keltezéssel, Mattias Gaertner írta:
> There is no option yet.
>
> It is done by TClassPropertyEditor.GetValue in unit propedits.pp.
>
> Feel free to implement an option.

I created a property and attached the patch. Please review.

Gabor
-------------- next part --------------
Index: components/ideintf/objectinspector.pp
===================================================================
--- components/ideintf/objectinspector.pp	(revision 50318)
+++ components/ideintf/objectinspector.pp	(working copy)
@@ -295,6 +295,7 @@
     FActiveRowBmp: TCustomBitmap;
     FFirstClickTime: DWORD;
     FKeySearchText: string;
+    FHideClassNames: Boolean;
 
     // hint stuff
     FHintTimer: TTimer;
@@ -507,6 +508,7 @@
     property TopY: integer read FTopY write SetTopY default 0;
     property Favorites: TOIFavoriteProperties read FFavorites write SetFavorites;
     property Filter : TTypeKinds read FFilter write SetFilter;
+    property HideClassNames: Boolean read FHideClassNames write FHideClassNames;
   end;
 
 
@@ -1744,7 +1746,7 @@
       ValueEdit.ReadOnly:=NewRow.IsReadOnly;
       ValueEdit.Enabled:=true;
       ValueEdit.MaxLength:=NewRow.Editor.GetEditLimit;
-      ValueEdit.Text:=NewValue;
+      if (FHideClassNames and (Rows[FItemIndex].Editor is TClassPropertyEditor)) then ValueEdit.Text:='' else ValueEdit.Text:=NewValue;
     end;
     AlignEditComponents;
     if FCurrentEdit<>nil then
@@ -2797,7 +2799,7 @@
     Font:=OldFont;
 
     // draw value
-    if ARow<>ItemIndex
+    if (ARow<>ItemIndex) and not (FHideClassNames and (CurRow.Editor is TClassProperty))
     then begin
       OldFont:=Font;
       if CurRow.Editor.IsNotDefaultValue then


More information about the Lazarus mailing list