Autor Beitrag
Matthias-K
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271

Win95, Win98, Win2000, WinXP, Linux
D2, D4 Client/Server, D5 Enterprise, D6 Enterprise, D7 Enterprise, Delphi2005, C/C++ 3.0, C/C ++ 5.0, C/C++ 6.0
BeitragVerfasst: Do 06.01.05 17:50 
hi leutz! ich hab mir jetzt die finger wund gehaun, und versucht, das zu lösen.

und zwar hab ich ein stringgrid, diese benutze ich als kalender. nun will ich die tage, die zum wochenende gehören, farblich hervorheben.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.FormCreate(Sender: TObject);
begin
  for a := 0 to stringgrid1.ColCount - 1 do
  begin
    stringgrid1.Cells[a,0] := DateToStr(now + a);
    if (DayOfTheWeek(now + a) = 6) or (DayOfTheWeek(now + a) = 7) then
    begin
      for i := 0 to stringgrid1.RowCount - 1 do
      begin
        // Zelle markieren
      end;
    end;
  end;
end;


dort, wo zelle markieren steht, komm ich net weiter, ich habs mit ondrawcell probiert, komm ich net weiter, und freundlicherweise hat mir meine hilfe den dienst versagt! das grid hat 31 spalten, und 30 zeilen, es ist erforderlich, das die spalte, welche den tag symbolisiert, komplett eingefärbt wird.

wie geht das am einfachsten?

mfg matthias
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: Do 06.01.05 18:12 
Hallo,

färben geht nur übers ondrawcell-ereignis, du findest hunderte Code-Beispiele im Forum, wenn du danach suchst, einfach acol auswerten und die farbe entsprechend setzen.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 06.01.05 18:52 
Zum Beispiel (aus einem meiner Projekte: Fehlzeitenplaner):
ausblenden volle Höhe 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:
31:
32:
33:
34:
35:
procedure TfrmMain.grdKalenderDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  RectLinks : TRect;
  RectRechts : TRect;
begin
  if (ACol > 0) and (ARow > 0) then begin
    //Initialisierung
    Rect.Bottom := Rect.Bottom-1;
    Rect.Right := Rect.Right-1;
    Rect.Top := Rect.Top+1;
    Rect.Left := Rect.Left+1;
    RectLinks.Top := Rect.Top;
    RectLinks.Right := Rect.Left + (Rect.Right - Rect.Left) div 2;
    RectLinks.Left := Rect.Left;
    RectLinks.Bottom := Rect.Bottom;
    RectRechts.Top := Rect.Top;
    RectRechts.Right := Rect.Right;
    RectRechts.Left := Rect.Left + (Rect.Right - Rect.Left) div 2;
    RectRechts.Bottom := Rect.Bottom;

    grdKalender.Canvas.Brush.Color := Liste[ARow,ACol].Links;
    grdKalender.Canvas.FillRect(RectLinks);
    grdKalender.Canvas.TextRect(RectLinks, RectLinks.Left + 1, RectLinks.Top + 1, copy(Liste[ARow,ACol].Text,1,1));

    grdKalender.Canvas.Brush.Color := Liste[ARow,ACol].Rechts;
    grdKalender.Canvas.FillRect(RectRechts);
    grdKalender.Canvas.TextRect(RectRechts, RectRechts.Left + 1, RectRechts.Top + 1, copy(Liste[ARow,ACol].Text,2,1));

    if (grdKalender.Selection.Left <= ACol) and (grdKalender.Selection.Right >= ACol) and
       (grdKalender.Selection.Top <= ARow) and (grdKalender.Selection.Bottom >= ARow) then begin
      grdKalender.Canvas.Brush.Color := TColor(Integer(grdKalender.Canvas.Brush.Color) xor $00FFFFFF);
      grdKalender.Canvas.FrameRect(Rect);
    end;
  end;
end;

Dabei geht es auch um halbe Urlaubstage (RectLinks und RecRechts), Die im Array "Liste" verwaltet werden. Bastel ein bisschen damit rum, dann sollte es eigentlich funktionieren. Ich war zu faul, meinen Kram aus dem Source zu entfernen. Aber vielleicht brauchst du ja genau das.