Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Inhalt von TRichEdit ohne Verlust von DefAttributes kopieren (https://www.delphipraxis.net/53423-inhalt-von-trichedit-ohne-verlust-von-defattributes-kopieren.html)

smart 16. Sep 2005 07:58


Inhalt von TRichEdit ohne Verlust von DefAttributes kopieren
 
Wenn man 1 TRichEdit und 1 TDBRichEdit auf einer Form hat und möchte den Text vom TRichEdit in dem TDBRichEdit kopieren, wie macht man das ohne die DefAttributes zu verlieren.
Delphi-Quellcode:
TDBRichEdit1.Text := RichEdit2.Text;
geht nicht. Alle DefAttributes gehen verloren.

Sharky 16. Sep 2005 08:08

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Hai Heike,

meinst Du so etwas: ?
Delphi-Quellcode:
Procedure CopyRichEdit (aSource, aDestination : TRichEdit);
var
  RichStream : TMemoryStream;
begin
  RichStream := TMemoryStream.Create;
  try
    aSource.Lines.SaveToStream(RichStream);
    RichStream.Position := 0;
    aDestination.Lines.LoadFromStream(RichStream);
  finally
    RichStream.Free;
  end;
end;

smart 16. Sep 2005 08:35

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Sorry, Ich habe es falsch dargestellt. Den Text von einem TRichEdit in einem TDBRichEdit kopieren, ohne dass farbiger Text usw. verloren geht.

Sharky 16. Sep 2005 09:23

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Geht das nicht mit dem Code oben wenn Du aDestitination nicht als TRichEdit sondern TDBRichEdit deklarierst?

shmia 16. Sep 2005 09:34

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Schon versucht: ??
Delphi-Quellcode:
TDBRichEdit1.lines.Assign(RichEdit2.Lines);

smart 16. Sep 2005 09:54

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Zitat:

Zitat von shmia
Schon versucht: ??
Delphi-Quellcode:
TDBRichEdit1.lines.Assign(RichEdit2.Lines);

Ja, habe ich versucht. Geht aber leider auch nicht.

smart 16. Sep 2005 09:57

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Zitat:

Zitat von Sharky
Geht das nicht mit dem Code oben wenn Du aDestitination nicht als TRichEdit sondern TDBRichEdit deklarierst?

Dann bekomme ich eine Fehlermeldung, dass die Typen nicht gleich sind.

shmia 16. Sep 2005 09:59

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Dann hier noch eine weitere Variante:
Delphi-Quellcode:
Procedure CopyRichEditLines(aSource, aDestination : TStrings);
var
  RichStream : TMemoryStream;
begin
  RichStream := TMemoryStream.Create;
  try
    aSource.SaveToStream(RichStream);
    RichStream.Position := 0;
    aDestination.LoadFromStream(RichStream);
  finally
    RichStream.Free;
  end;
end;
Anwendung:
Delphi-Quellcode:
Query1.Edit; // wir müssen im Edit-Mode sein
CopyRichEditLines(RichEdit1.Lines, DBRichEdit1.Lines);

smart 16. Sep 2005 10:44

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Zitat:

Zitat von shmia
Dann hier noch eine weitere Variante:

Vielen Dank für Deine Mühe. Klappt aber auch nicht.

Sharky 16. Sep 2005 10:57

Re: Inhalt von TRichEdit ohne Verlust von DefAttributes kopi
 
Zitat:

Zitat von smart
..Klappt aber auch nicht.

Kannst Du mal ein kurzes Demoprojekt anhängen?


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:02 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz