AGB  ·  Datenschutz  ·  Impressum  







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

JvInspector: "Enum-Item" hinzufügen

Ein Thema von Basic-Master · begonnen am 14. Aug 2005 · letzter Beitrag vom 14. Aug 2005
Antwort Antwort
jbg

Registriert seit: 12. Jun 2002
3.485 Beiträge
 
Delphi 10.1 Berlin Professional
 
#1

Re: JvInspector: "Enum-Item" hinzufügen

  Alt 14. Aug 2005, 18:06
Zitat von Basic-Master:
das New() in meiner Funktion ist notwendig
Ob es notwendig ist, habe ich nicht gefragt, sondern ob du dich auch wieder um das Freigeben des Speichers kümmerst, oder ein Speicherleck hast.

Zitat:
Ich suche im Moment leider eher eine Möglichkeit, Strings wie "||" und "&&" [im Style einer ComboBox; wie eben Enums] hinzuzufügen
Das hättest du vielleicht auch mal oben erwähnen können. (Hellsehen ist nicht meine stärke)

Delphi-Quellcode:
type
  TSelectionTextList = class(TStringList)
  private
    FSelected: Integer;
    function GetSelectedText: string;
    function GetSelected: Integer;
    procedure SetSelectedText(const Value: string);
    procedure SetSelected(const Value: Integer);
  public
    property Selected: Integer read GetSelected write SetSelected;
    property SelectedText: string read GetSelectedText write SetSelectedText;
  end;

  TJvInspectorSelectionTextListItem = class(TJvCustomInspectorItem)
  protected
    function GetDisplayValue: string; override;
    procedure GetValueList(const Strings: TStrings); override;
    procedure SetDisplayValue(const Value: string); override;
    procedure SetFlags(const Value: TInspectorItemFlags); override;
  end;

{ TSelectionTextList }

function TSelectionTextList.GetSelected: Integer;
begin
  if FSelected < -1 then
    FSelected := -1
  else if FSelected >= Count then
    FSelected := Count - 1;
  Result := FSelected;
end;

function TSelectionTextList.GetSelectedText: string;
begin
  if Selected >= 0 then
    Result := Strings[Selected]
  else
    Result := '';
end;

procedure TSelectionTextList.SetSelected(const Value: Integer);
begin
  FSelected := Value;
  GetSelected; // adjust FSelected
end;

procedure TSelectionTextList.SetSelectedText(const Value: string);
begin
  FSelected := IndexOf(Value);
end;

{ TJvInspectorSelectionTextListItem }

function TJvInspectorSelectionTextListItem.GetDisplayValue: string;
begin
  Result := TSelectionTextList(Data.AsOrdinal).SelectedText;
end;

procedure TJvInspectorSelectionTextListItem.GetValueList(const Strings: TStrings);
begin
  Strings.Assign(TSelectionTextList(Data.AsOrdinal));
end;

procedure TJvInspectorSelectionTextListItem.SetDisplayValue(const Value: string);
begin
  TSelectionTextList(Data.AsOrdinal).SelectedText := Value;
end;

procedure TJvInspectorSelectionTextListItem.SetFlags(const Value: TInspectorItemFlags);
begin
  inherited SetFlags(Value + [iifValueList]);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FMyList := TSelectionTextList.Create;
  FMyList.Add('Blau');
  FMyList.Add('Grün');
  FMyList.Add('Weiß');
  FMyList.Add('Gelb');

  TJvCustomInspectorData.ItemRegister.Add(TJvInspectorTypeInfoRegItem.Create(TJvInspectorSelectionTextListItem, TypeInfo(TSelectionTextList)));

  TJvInspectorVarData.New(JvInspector1.Root, 'MyList', TypeInfo(TSelectionTextList), @FMyList);
end;

...
  Mit Zitat antworten Zitat
Antwort Antwort


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 15:24 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