0

私はDelphiから始めます。TStringGrid と Colored the Cell に問題があります。が選択されているときにBackGroundに色を付けるためにこのコードを使用しています:

procedure TForm_Matrix.MatrizGeneralDrawCell(Sender: TObject;
  ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
  ACol:=MatrizGeneral.Col;
  ARow:=MatrizGeneral.Row;
  begin
    if (RBAlto.Checked = True) then // Nivel de color ROJO - ALTO
      MatrizGeneral.Canvas.Brush.Color :=clRed;
      MatrizGeneral.Canvas.FillRect(Rect);
    if (RBMedio.Checked = True) then
      MatrizGeneral.Canvas.Brush.Color :=clYellow;
      MatrizGeneral.Canvas.FillRect(Rect);
    if (RBBajo.Checked = True) then
      MatrizGeneral.Canvas.Brush.Color :=clLime;
      MatrizGeneral.Canvas.FillRect(Rect);
  end;
end;

その作業ですが、色を変更しようとすると、選択したセルが変更され、最初のセルが理由を識別します。

  1. 赤の3つのセルを選択すると。(うまくいきます) ここに画像の説明を入力

  2. 別のセルの色を変更、最初のセルを変更 TT ここに画像の説明を入力

    http://i.stack.imgur.com/umG0r.png http://i.stack.imgur.com/1o93C.png

ヘルプ!!!

4

2 に答える 2

0

ラジオグループで選択されたセルに色を付けるために、このルーチンを使用します。

if MatrizGeneral.Cells[ACol,ARow] <> '' then begin
case StrToInt(MatrizGeneral.Cells[ACol,ARow]) of
  0: BGColor := clRed;
  1: BGColor := clYellow;
  2: BGColor := clLime;
else
  BGColor := clWhite;
end;
with MatrizGeneral do begin
  Canvas.Brush.Color := BGColor;
  Canvas.FillRect(Rect);

  if (gdFocused in State) then
    Canvas.Font.Color := clWhite
  else
    Canvas.Font.Color := clBlack;
end;

終わり;

よく働く!

于 2014-03-19T14:13:57.027 に答える