Autor Beitrag
AlexII
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Sa 06.10.07 11:51 
Wie mache ich es, dass auf der Titelzeile neben dem Titel ein Pfeil "nach oben" und nach dem drücken "nach unten" steht? Ist für die Sortierung gedacht.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 06.10.07 12:05 
Ich glaube, dass das normale Stringgrid sowas nicht kann. Ich nutze für so ne Art Anzeige den VirtualTreeView, der ist auch sonst schöner für den User in der Anwendung. Evtl. gehts aber auch mit Listview oder ähnlichem :nixweiss:

_________________
We are, we were and will not be.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 06.10.07 14:47 
Hallo,

stimmt, das StringGrid kann es direkt nicht, aber es sind doch nur Dreiecke, die man in OnDrawCell zeichnen kann.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
Polygon([Point(aRect.Left+6,aRect.Top+13),
         Point(aRect.Left+10,aRect.Top+9),
         Point(aRect.Left+14,aRect.Top+13)]);
//und anders herum
Polygon([Point(aRect.Left+6,aRect.Top+9),
         Point(aRect.Left+14,aRect.Top+9),
         Point(aRect.Left+10,aRect.Top+13)]);

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
AlexII Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 180



BeitragVerfasst: Sa 06.10.07 15:01 
Lannes danke für den Tipp, aber kannst du vllt sagen wie das genauer geht ... wo was eintragen :nixweiss:
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 06.10.07 16:07 
Hallo,

der Code muss in der OnDrawCell-Ereignisbehandlungsmethode stehen.
Also im OI bei Ereignisse Doppelklick hinter OnDrawCell und du bekommst den Prozedurrumpf von Delphi erzeugt.
OnDrawCell wird ausgelöst wenn ein Teil des Grids neu gezeichnet werden muss, ausgelöst wird es für jede Zelle einzeln.

Weis jetzt nicht wie dein Grid sortiert wird, ab alle Spalten sortierbar sind ...
So im Groben, angenommen in einer Variable "aSortCol" wird die sortierte Spalte gemerkt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if ARow = 0 then//in der ersten Zeile sollen die Pfeile gezeichnet werden.
    begin
    // hier mit FillRect altes übermalen
    if aSortCol = ACol then    
      Polygon(...)
      else
        Polygon(...)
    //hier mit TextOut oder DrawText den Text ausgeben, neben dem Dreieck!
    end;
end;


Ps.: zum Zeichnen in OnDrawCell findest Du so einiges hier im Forum.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )