AGB  ·  Datenschutz  ·  Impressum  







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

DSharp, DevExpress Editors, Bindings

Ein Thema von mytbo · begonnen am 23. Aug 2019 · letzter Beitrag vom 10. Sep 2019
Antwort Antwort
Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.045 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#1

AW: DSharp, DevExpress Editors, Bindings

  Alt 10. Sep 2019, 11:18
Delphi-Quellcode:
type
  TcxTextEdit = class(cxTextEdit.TcxTextEdit, INotifyPropertyChanged)
  private
    FNotifyPropertyChanged: TNotifyPropertyChanged;
    property NotifyPropertyChanged: TNotifyPropertyChanged
      read FNotifyPropertyChanged implements INotifyPropertyChanged;
    procedure WMChar(var Message: TWMChar); message WM_CHAR;
  protected
    procedure DoTextChanged; override;
    procedure CMExit(var Message: TCMExit); message CM_EXIT;
  public
    constructor Create(AOwner: TComponent); override;
  end;

procedure TcxTextEdit.CMExit(var Message: TCMExit);
begin
  try
    FNotifyPropertyChanged.NotifyOfPropertyChange('Text', utLostFocus);
    inherited;
  except
    on EValidationError do
    begin
      SetFocus;
    end;
  end;
end;

constructor TcxTextEdit.Create(AOwner: TComponent);
begin
  inherited;
  FNotifyPropertyChanged := TNotifyPropertyChanged.Create(Self);
end;

procedure TcxTextEdit.DoTextChanged;
begin
  inherited;
  FNotifyPropertyChanged.NotifyOfPropertyChange('Text');
end;

procedure TcxTextEdit.WMChar(var Message: TWMChar);
begin
  inherited;
  if Message.CharCode = VK_RETURN then
  begin
    FNotifyPropertyChanged.NotifyOfPropertyChange('Text', utExplicit);
  end;
end;
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  Mit Zitat antworten Zitat
mytbo

Registriert seit: 8. Jan 2007
482 Beiträge
 
#2

AW: DSharp, DevExpress Editors, Bindings

  Alt 10. Sep 2019, 13:55
Hallo!

Danke für den Quellcode.

Beruhigend! Eine Eins-zu-eins-Umsetzung wie in meinem Testbeispiel. Wenn sich alle DevExpress Editors so eng an ihr VCL-Pendant anlehnen und keine Fallstricke lauern, ist die Umsetzung wirklich kein Problem. Nochmals vielen Dank für DSharp.

Bis bald...
Thomas
  Mit Zitat antworten Zitat
mytbo

Registriert seit: 8. Jan 2007
482 Beiträge
 
#3

AW: DSharp, DevExpress Editors, Bindings

  Alt 10. Sep 2019, 18:46
Hallo!

Noch eine Frage zur Source-Kosmetik. Spricht etwas dagegen, in der SubKlasse gleich folgendes zu schreiben:
Code:
public
  function AddBinding(pmSourceObject: TObject;
    const pmcSourcePropertyName: String; pmBindingGroup: TBindingGroup = Nil): TBinding;

function TcxTextEdit.AddBinding(pmSourceObject: TObject;
  const pmcSourcePropertyName: String; pmBindingGroup: TBindingGroup): TBinding;
begin
  Assert(pmSourceObject <> Nil);
  Assert(pmcSourcePropertyName <> '');

  if pmBindingGroup = Nil then
    pmBindingGroup := FindBindingGroup(Self.Owner);

  if pmBindingGroup <> Nil then
    Result := pmBindingGroup.AddBinding(pmSourceObject, pmcSourcePropertyName, Self, TEXTEDIT_BINDING_PROPNAME, bmTwoWay)
  else
    Result := TBinding.Create(pmSourceObject, pmcSourcePropertyName, Self, TEXTEDIT_BINDING_PROPNAME);
end;
Dann reicht im Form z.B.: edtVorname.AddBinding(SourceObject, 'Vorname');

Bis bald...
Thomas
  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 14:46 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