Autor Beitrag
juergen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Mi 08.09.04 13:14 
Habe folgendes Problem:

In einem Stringgrid möchte ich bestimmte Zeilen "readonly" setzen und diese Farblich kennzeichnen.
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:
procedure Tprodukt_anlegen_form.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
        with stringgrid1 do
        begin
        if (arow in [1,3,8,11]) and (acol<>0) and (arow<>0) 
        then
        begin
        Canvas.Brush.Color := clred;
        Canvas.FillRect(Rect);
        canvas.textout(rect.Left,rect.Top,cells[acol,arow]);
        Options:=options-[goEditing];
        end
        else
        if (acol<>0) and (arow<>0)  then
        begin
        Canvas.Brush.Color := clwindow;
        Canvas.FillRect(Rect);
        canvas.textout(rect.Left,rect.Top,cells[acol,arow]);
        Options:=options+[goEditing];
        end;
 end;


end;


Dieses führt zu einer Endlosschleife.

WARUM ?

DANKE
juergen
Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mi 08.09.04 13:17 
Sehr wahrscheinlich löst das Ändern der Optionen das erneute Zeichnen aus. Das "Readonly-Schalten" solltest du auch an einer anderen Stelle vornehmen, DrawCell ist da nicht das richtige.

Cu,
Udontknow
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Mi 08.09.04 13:22 
Genau, ReadOnlz solltest Du in OnSelectCell implementieren, die farblcihe Hervorhebung machst Du dann weiterhin in DrawCell
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Mi 08.09.04 13:40 
Vielen Dank !
so läufts

juergen