Autor Beitrag
Stauch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 140

Win 2000, Win XP
D4
BeitragVerfasst: Mi 25.02.04 11:52 
Folgendes kleines Problemchen:

Läßt sich eine Zelle eine Stringrids überreden, einen Text, der für die entsprechende Spalte zu lang ist, auf mehrere Zeilen Zeilen zu verteilen?

C. :?:

_________________
Geht das? Und wenn ja, warum nicht?
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Mi 25.02.04 13:12 
Hallo

innerhalb der Zelle oder über mehrere "rows"?

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Mi 25.02.04 15:12 
hallo C !

ich kenne zwar die eigenschaft 'zeilen.zeilen' in einem stringgrid nicht, aber mit 'colspan' lassen sich mehrere zellen zusammenhängen

Zitat:
Die untenstehende Procedure verbindet die erste Zeile hinter der Fixed-Zeile/Spalte zu einer einzigen Zeile:

ausblenden 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:
{UNTESTED}
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, 
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  i, x, y: Integer;
begin
  If gdFixed In State Then 
    Exit;
  If ARow > 1 Then 
    Exit;

  with sender as tstringgrid do 
  begin
    If aCol < Pred(ColCount) Then
      Rect.Right := Rect.Right + GridlineWidth;

    y:= Rect.Top + 2;
    x:= Rect.Left + 2;
    for i:= 1 to aCol-1 do
      x:= x - ColWidths[i] - GridlineWidth;

    Canvas.Brush.Color := clYellow;
    Canvas.Brush.Style := bsSolid;
    Canvas.FillRect( Rect );

    Canvas.TextRect( Rect, x, y, Cells[1,1] );
  end;
end;

Quelle: EDH


mfg, stefan
Stauch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 140

Win 2000, Win XP
D4
BeitragVerfasst: Do 26.02.04 09:10 
@Keldorn
innerhalb der Zelle
@grayfox
Zitat:
zeilen.zeilen - da hab ich wohl ein wenig hastig getippt :wink:

Aber colspan ist nicht dass, was ich meine. Jetzt mal angenommen, ich habe 2 Zeilen/2 spalten
Etwa
Zelle11 Zelle21
Zelle12 Zelle22

In drei Zellen steht jeweils 1 Wort in Zelle 22 ein ganzer Satz, der soll aber, wenn er die Breite der 2. Spalte überschreitet, innerhalb der Zelle(s.o.) umgebrochen werden.

C.

_________________
Geht das? Und wenn ja, warum nicht?
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 26.02.04 14:47 
hallo C !

da bleibt dir nur die möglichkeit, das ausfüllen des stringgrid selbst vorzunehmen...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
DrawText(StringGrid1.Canvas.Handle,
  PChar(Text),
  length(Text),
  outRect,
  DT_Left //=Linksbündig, DT_Center=Zentiert, DT_Right=Rechtsbündig
  or
  DT_WordBreak); //=Umbruch, DT_SingleLine=ohne Umbruch


Quelle: home.arcor.de/hardco...nload/stringgrid.pdf

mfg, stefan
Stauch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 140

Win 2000, Win XP
D4
BeitragVerfasst: Fr 27.02.04 11:26 
Das ist 'ne geniale Idee, auf die API - zurückzugreifen. Danke!

MfG Carsten
:)

_________________
Geht das? Und wenn ja, warum nicht?
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Fr 27.02.04 17:05 
hallo carsten!

es freut mich, dass dir mein vorschlag gefällt. hoffentlich nützt er dir auch was ;)

mfg, stefan