Autor Beitrag
mtm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

Windows 10 Pro 64 Bit
Delphi XE 6
BeitragVerfasst: Mi 07.04.10 00:10 
Hallo zusammen !
Ich habe ein kleines Problemchen. Ich bin noch nicht so 100%-ig Firm in Delphi. Ich möchte ein Stringgrid mit einem Click auf die Kopfzeile sortieren. Das klappt eigentlich auch schon ganz gut. Ich habe außerdem mit "Canvas.Draw" ein Icon in die entsprechende Kopf-Zelle gesetzt. Wenn ich aber danach die Breite per Maus verändere, ist das Icon wieder verschwunden.
Wie kriege ich es hin, daß das Icon permanent (bis zum Programmende) in der entsprechenden Zelle bleibt.

danke im Voraus
mtm


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mi 07.04.2010 um 00:31
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10184
Erhaltene Danke: 1259

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 07.04.10 00:41 
Moin und :welcome: im Forum!

user profile iconmtm hat folgendes geschrieben Zum zitierten Posting springen:
Ich habe außerdem mit "Canvas.Draw" ein Icon in die entsprechende Kopf-Zelle gesetzt. Wenn ich aber danach die Breite per Maus verändere, ist das Icon wieder verschwunden.
Wie kriege ich es hin, daß das Icon permanent (bis zum Programmende) in der entsprechenden Zelle bleibt.
Hört sich so an (Code hast du ja keinen gezeigt ;)), als ob du nicht die dafür vorgesehenen Ereignisse verwendest. Mit diesem Beispiel kannst du alle fixen Zellen grün und die Zelle links/oben rot einfärben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if (gdFixed in State) then begin // Zelle im festen Bereich?
    if (ACol = 0and (ARow = 0then // links/oben?
      StringGrid1.Canvas.Brush.Color := clRed
    else
      StringGrid1.Canvas.Brush.Color := clLime;
    StringGrid1.Canvas.Rectangle(Rect); // Rechteck zeichnen
  end;
end;
Also entsprechenden Ereignishandler anlegen und den Code für deine Zwecke anpassen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
mtm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64

Windows 10 Pro 64 Bit
Delphi XE 6
BeitragVerfasst: Mi 07.04.10 11:35 
Super, es funzt !!!
Danke Dir.

P.S. : Beim nächsten mal werde ich auch den Code angeben. :)