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 Problem mit record (https://www.delphipraxis.net/93646-problem-mit-record.html)

The_ New_Guy 8. Jun 2007 20:56


Problem mit record
 
Ich brauche ein ein mehrdimensionales array, indem ich die eigenschaften font und color einspeichere.
hier die deklaration:
Delphi-Quellcode:
type
  Tcell_attributes = array of array of Record
    Font : Tfont;
    color : Tcolor;
end;
//...
var ca : Tcell_attributes;
//...
ca[x,y].font := // . . .
Mein Problem: wie kann ich überprüfen ob der wert in ca[x,y].font schon gesetzt ist,
also ob da schon was reingeschrieben wurde -?

mkinzler 8. Jun 2007 20:58

Re: Problem mit record
 
Auf Nil prüfen bzw. Assigned()

The_ New_Guy 8. Jun 2007 20:59

Re: Problem mit record
 
ich habe verucht die länge des arrays zu bestimmen, allerdings stürzt meine Anwendung dann auch immer ab

etwa so
Delphi-Quellcode:
  setlength(ca1,stringgrid1.Colcount);
  for x := 1 to stringgrid1.Colcount-1 do
    setlength(ca1[x], stringgrid1.RowCount);

The_ New_Guy 8. Jun 2007 20:59

Re: Problem mit record
 
nil geht leider nicht - ich probier mal assigned

The_ New_Guy 8. Jun 2007 21:29

Re: Problem mit record
 
funktioniert leider nicht . . .

The_ New_Guy 8. Jun 2007 21:31

Re: Problem mit record
 
Liste der Anhänge anzeigen (Anzahl: 1)
assignd funktioniert allerdings geht der code nicht richtig . . .
also ich versuche alle Zellen in einem Stringgrid mit font und color eigenschaften zu belegen.
mit color funktioniert das wunderbar - allerdings nicht mit font.

Delphi-Quellcode:

procedure Temaske_excel.Schriftartbearbeiten1Click(Sender: TObject);
begin

if Assigned(ca1[stringgrid1.Col,stringgrid1.Row].font) then
  fontdialog1.Font := ca1[stringgrid1.Col,stringgrid1.Row].font
else
  fontdialog1.Font := stdfont;

if fontdialog1.Execute then
begin
  ca1[stringgrid1.Col,stringgrid1.Row].font := fontdialog1.Font;
end;

end;
das problem : wenn ich eine zelle anklicke, das popupmenü öffen und denn auf 'schriftarten bearbeiten' klicke wird der font wert stdfont nicht richtig in den fontdialog1 eingefügt.
der fontdialog1 sollte dann doch eigentlich stdfont anzeigen, oder?

in der oncreate definiere ich stdfont so:
Delphi-Quellcode:
stdfont := Fontdialog1.font;

DeddyH 8. Jun 2007 21:35

Re: Problem mit record
 
Zitat:

Zitat von The_New_Guy
mit color funktioniert das wunderbar - allerdings nicht mit font.

Das könnte daran liegen, dass TFont eine Klasse ist, TColor hingegen nicht :zwinker: .

The_ New_Guy 8. Jun 2007 21:38

Re: Problem mit record
 
ahh daddy hat ahnung!(cool) wie bekomme ich das hin? muss ich da mit create arbeiten?

DeddyH 8. Jun 2007 21:39

Re: Problem mit record
 
Haargenau, Du musst eine Klasse erst instanziieren. Vergiss aber bitte nicht, den belegten Speicher zum Schluss wieder freizugeben.

The_ New_Guy 11. Jun 2007 18:15

Re: Problem mit record
 
villeicht noch ein kleines Beispiel . . .

das ist doch ein array - muss ich jedes element einzelnd createn d.h. für die ganze Matrix
einzelnd?`oder gibts ne lösung das besser hinzubekommen. Was ist mit font selber - muss ich auch ein tfont objekt erzeugen?


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:09 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