Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.10.11 10:26 
Hi, Delpher,

(wie) kann ich die Feldgröße so auslesen, dass ein Stringgrid dann die geeignete Feldbreite hat?

ausblenden Delphi-Quelltext
1:
stringgrid1.colwidths[n] := Tx.fields[n].fieldsize;					


So geht es leider nicht!

Danke, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 03.10.11 12:47 
Du kannst mit TCanvas.GetTextWidth die Breite der Schrift auslesen und diese als Grundlage nehmen.

Aber wie ich am Thread-Status sehe, hast Du ja bereits eine Lösung, die Du uns nicht verraten willst ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 03.10.11 12:56 
Klar doch:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
with stringgrid1 do
  begin
    colcount := Qx.fieldcount;
    for n := 0 to Qx.fieldcount-1 do
    begin
      cells[n,0] := Qx.fields[n].FieldName;  //   showmessage(inttostr(Qx.Fields[n].datasize));
      if canvas.TextWidth(Qx.fields[n].asstring) < colwidths[n] then
        colwidths[n] := 6 * Qx.fields[n].datasize;
      if uppercase(Qx.fields[n].FieldName) = 'GEBDAT' then colwidths[n] := DefaultColWidth;
      cells[n,1] := Qx.Fields[n].asstring;
    end;
  end;


:) Detlef

P.S. wäre schön, wenn es noch eine Antwort zu meinem Excel2Dbf-Thread gäbe :)(:

_________________
ut vires desint, tamen est laudanda voluntas