Autor Beitrag
Flash106
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Di 28.12.04 21:03 
Hallo.

Ich habe ein Stringgrid zweifarbig eingefärbt, so das die Zeilen sich farblich immer abwechseln. Wenn ich nun aber eine Zeile markieren sieht man die markierung nicht und die schriftfarbe ist weis... da ich einige zeilen aber weis habe sieht man dann gar nichts mehr.. wie kann ich die markierung festlegen?? Also sagen die markierte Zeile soll einen roten Rahmen haben oder farblich anders hinterlegt sein...
Wäre toll wenn mir jemand helfen könnte =)

Bianca


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Do 30.12.2004 um 11:22
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 28.12.04 21:31 
wie hast du die Zeilen gefärbt ?
das selbe kannst du dann ja mit den Zeilen in Stringgrid1.Selection machen
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Di 28.12.04 22:08 
Im OnDrawCell - von dem ich annehme, dass du da die farbliche Markierung gemacht hast - kannst du genauso die Selection abfragen und "Custom"-färben.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Mi 29.12.04 14:08 
Egal wo ich den source zum ändern der Farbe rein setze es ändert sich nichts. Das blöde ist das er die Textfarbe in der markierten Zeile auf weiss setzt und er somit nicht mehr lesbar ist.
Hab bei OnSelectCell folgendes hinzugefügt:

ausblenden Quelltext
1:
  strgrdTeilnehmer.Font.Color := clBlack;					


hilfe?! :?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 29.12.04 14:09 
Zeig mal den kompletten Source.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Mi 29.12.04 14:18 
also im OnSelectCell steht nix weiter und im OnDrawCell steht folgendes:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
  strgrdTeilnehmer.Font.Color := clBlack;
  with (Sender as TStringGrid) do
  begin
  if ARow = 0 then Canvas.Brush.Color := $00C9AFAF

  else
      if ARow mod 2 = 0 then
        Canvas.Brush.Color := $00F4EFEF
      else
        Canvas.Brush.Color := clWhite;
      Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
      Canvas.FrameRect(Rect);
    end;


Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 29.12.04 14:26 
Dann kannst du das so erweitern:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
 strgrdTeilnehmer.Font.Color := clBlack;
  with (Sender as TStringGrid) do
  begin
  if ARow = 0 then Canvas.Brush.Color := $00C9AFAF


  else
      if ARow mod 2 = 0 then
      begin
        Canvas.Brush.Color := $00F4EFEF
        if Selection.Top = ARow then Canvas.Brush.Color := ...
      end else
      begin
        Canvas.Brush.Color := clWhite;
        if Selection.Top = ARow then Canvas.Brush.Color := ...
      end;
      Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
      Canvas.FrameRect(Rect);
    end;

Das Beispiel ist jetzt für zeilenweise Auswahl und ohne Multiselect. Bei Bedarf müsstest du das auf den jeweiligen Bereich erweitern.

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
Flash106 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 234


D7 Ent
BeitragVerfasst: Mi 29.12.04 14:39 
Danke!!! :D
Funktioniert!!!