AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Verwenden des PropertyGrids?

Ein Thema von Alexander · begonnen am 10. Feb 2007 · letzter Beitrag vom 11. Feb 2007
 
Alexander

Registriert seit: 28. Aug 2002
Ort: Oldenburg
3.513 Beiträge
 
Turbo Delphi für .NET
 
#6

Re: Verwenden des PropertyGrids?

  Alt 11. Feb 2007, 11:46
Sooo. Ich probiere schon den ganzen Morgen am CustomPropertyGrid von CodeProject.com herum.
Leider kann ich die DisplayName Attribute noch immer nicht ändern .

Irgendetwas scheine ich falsch zu machen. Dabei dachte ich, dass ich den C# Code auf CodeProject vollständig übersetzt habe.

Hier mal mein Code:
Delphi-Quellcode:
  TSetting = class
  private
    FVarName : String;
    FDefaultText : String;
    FDefaultTextDisplayName : String;
    FTitle : String;
    FDescription : String;
    FValueLabel : String; // Im SQL-Text enthaltender Text

    procedure setVarName(s : String);
    function getVarName() : String;
    procedure setDefaultText(s : String);
    function getDefaultText() : String;
    procedure setTitle(s : String);
    function getTitle() : String;
    procedure setDescription(s : String);
    function getDescription() : String;
    procedure setValueLabel(s : String);
    function getValueLabel() : String;

    function getDefaultTextDisplayName() : String;
    procedure setDefaultTextDisplayName(s : String);

  published
    [Description('VarName'), System.ComponentModel.Browsable(true), DisplayName('Hallo')]
    property VarName : String read getVarName write setVarName;
//////////////////////////////////////
    [PropertyAttributesProvider('DynamicPropertyAttributesProvider'), System.ComponentModel.Browsable(true)]
    property DefaultText : String read getDefaultText write setDefaultText;

    [System.ComponentModel.Browsable(true)]
    property defaultTextDisplayName : String read getDefaultTextDisplayName write setDefaultTextDisplayName;
////////////////////////////////////////
    [System.ComponentModel.Browsable(true)]
    property Title : String read getTitle write setTitle;

    [System.ComponentModel.Browsable(true)]
    property Description : String read getDescription write setDescription;

    [System.ComponentModel.Browsable(true)]
    property ValueLabel : String read getValueLabel write setValueLabel;
  public
    procedure DynamicPropertyAttributesProvider(var attributes : PropertyAttributes);
  end;
{...}
procedure TSetting.DynamicPropertyAttributesProvider(var attributes : PropertyAttributes);
begin
  attributes.DisplayName := defaultTextDisplayName;
// attributes.IsReadOnly := dynamicPropertyIsReadOnly;
// attributes.IsBrowsable := dynamicPropertyIsVisible;
end;


{...}
{PropertyGrid erzeugen usw.}
constructor TSqlVarFrm.Create;
begin
  inherited Create;
  InitializeComponent;
  propertyGrid := FormsUtils.CustomPropertyGrid.Create;
 // statusBarEx := FormsUtils.StatusBarEx.Create;

  propertyGrid.CommandsVisibleIfAvailable := true;
  propertyGrid.ExpandOnTab := false;
  propertyGrid.LargeButtons := false;
  propertyGrid.LineColor := System.Drawing.SystemColors.ScrollBar;
  propertyGrid.Location := System.Drawing.Point.Create(0, 48);
  propertyGrid.Name := 'propertyGrid';
  propertyGrid.Size := System.Drawing.Size.Create(456, 272);
  propertyGrid.TabIndex := 3;
  propertyGrid.Text := 'customPropertyGrid1';
  propertyGrid.ViewBackColor := System.Drawing.SystemColors.Window;
  propertyGrid.ViewForeColor := System.Drawing.SystemColors.WindowText;
  propertyGrid.Dock := DockStyle.Fill;
  propertyGrid.Parent := self;

  FSqlVar := TSetting.Create;
  FSqlVar.VarName := 'Var';
  FSqlVar.DefaultText := 'Default';
  FSqlVar.Title := 'Titel';
  FSqlVar.Description := 'Desc';
  FSqlVar.ValueLabel := 'Label';
  FSqlVar.defaultTextDisplayName := 'Hallo Welt';

  PropertyGrid.SelectedObject := FSqlVar;
  propertyGrid.Refresh;
defaultTextDisplayName taucht zwar im PropertyGrid auf. Ich setze es ja im Code direkt auf einen Namen. Dann sollte dieser ja eigentlich als DisplayName von DefaultText auch direkt übernommen werden. Wenn ich das (wie in der Demo des Projektes auf CodeProject.com) zur Laufzeit verändere, dann klappt es auch nicht (auch mit einem Refresh danach nicht).

Ein direktes DisplayName-Attribut im Code in der TSettings-Klasse zeigt im Übrigen auch keine Wirkung.

Was habe ich nun wieder falsch gemacht? .
Wahrscheinlich läuft ja beim PropertyAttributesProvider irgendwas falsch (an der markierten Stelle im Code).
Oder doch wieder ne Delphi Eigenart?
Alexander
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:08 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz