Einzelnen Beitrag anzeigen

Benutzerbild von Schaedel
Schaedel

Registriert seit: 5. Jan 2006
Ort: Saarland
174 Beiträge
 
Delphi 2007 Professional
 
#7

Re: StringGrid-Komponente mit Checkbox

  Alt 3. Apr 2007, 08:31
Hi,

hier ein Beispiel wie du in eine bestimmte Col fortlaufend Checkboxen setzt....

Delphi-Quellcode:
DrawCell(Sender: TObject; ACol,ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  AktStr : string;
  SmallRect : TRect;
begin
  AktStr := trim(Grid.Cells[ACol, ARow]);
  if (AktStr = '0') then
    AktStr:='';
  if ((ACol=ChkCol1) or (ACol=ChkCol2)) and (ARow>=SGSndDat.FixedRows) then begin
    Grid.Canvas.FillRect(Rect);

    SmallRect:=Rect;
    SmallRect.Top:=Rect.Top + (Rect.Bottom - Rect.Top) div 2 - 7;
    SmallRect.Bottom:=SmallRect.Top + 15;

    if AktStr <> 'then begin
      DrawFrameControl(SGSndDat.Canvas.Handle,SmallRect,DFC_Button,DFCS_BUTTONCHECK or DFCS_CHECKED);
    end else begin
      DrawFrameControl(SGSndDat.Canvas.Handle,SmallRect,DFC_Button,DFCS_BUTTONCHECK);
    end;
  end else begin
    inherited;
  end;
end;
Wenn irgendetwas in der Cell steht ist die Checkbox checked!
Michael S.
  Mit Zitat antworten Zitat