Autor Beitrag
Gintonik
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66

Win MCE 2005
Delphi7 Enterpr.
BeitragVerfasst: Di 16.01.07 16:27 
Hallo,

ich habe eine Stringgrid die ich zur Laufzeit an die aktuelle Auflösung anpasse. Die Spaltebreite
DefaultColWidth soll sich auch automatisch maximieren, halt je nach dem die Auflösung ist.
Ich habe in TForm1.Resize denselben Befehl geschrieben wie bei TForm1.Create und leider reagiert der nur beim ändern der Auslösung darauf, dann macht er es auch so wie er es soll, halt nur nicht beim Programmstart.

Weis einer weiter?

Thx, Marcel...

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
procedure TForm1.FormCreate(Sender: TObject);
begin
res_width := screen.Width;
res_height := screen.Height;
// Labels an Stringgrid1 zur Laufzeit ausrichten
label5.Left := 0 + stringgrid1.DefaultColWidth + 15;
label6.Left := 0 + stringgrid1.DefaultColWidth * 2 + 15;
label7.Left := 0 + stringgrid1.DefaultColWidth * 3 + 15;
label8.Left := 0 + stringgrid1.DefaultColWidth * 4 + 15;
// Stringgrid1 auf max Größe bringen
stringgrid1.Height := pagecontrol1.ClientHeight - 270;
//stringgrid1 Spaltenbreite an aktuelle Auflösung anpassen ***** // HIER GEHTS LEIDER NICHT !!!  ***
stringgrid1.DefaultColWidth := stringgrid1.Width div 5 - 5;
// Buttons zur Spaltenbreitenänderung plazieren
button6.Top := pagecontrol1.Height - 45;
button7.Top := pagecontrol1.Height - 45;
end;

// UND HIER GEHTS PERFEKT !!!

procedure TForm1.FormResize(Sender: TObject);
begin
Pagecontrol1.Width := Form1.ClientWidth - 80;
Pagecontrol1.Height := Form1.ClientHeight - 80;
stringgrid1.DefaultColWidth := stringgrid1.Width div 5 - 5;   //*** GEHT PERFEKT !!! ***
Stringgrid1.Width := Pagecontrol1.Width - 30;
stringgrid1.Height := pagecontrol1.ClientHeight - 270;
button6.Top := pagecontrol1.Height - 45;
button7.Top := pagecontrol1.Height - 45;
label5.Left := 0 + stringgrid1.DefaultColWidth + 15;
label6.Left := 0 + stringgrid1.DefaultColWidth * 2 + 15;
label7.Left := 0 + stringgrid1.DefaultColWidth * 3 + 15;
label8.Left := 0 + stringgrid1.DefaultColWidth * 4 + 15;
end;
Gintonik Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 66

Win MCE 2005
Delphi7 Enterpr.
BeitragVerfasst: Di 16.01.07 16:47 
Der Teufel steckte im Detail...
Hab den Fehler gefunden.
Habe die Spaltenbreite neu berechnen lassen, bevor ich dem Stringgrid die neue Größe zugeordnet habe...