掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
stringgridでセルを比較して一致しなかったら色を付けるには? (ID:39252)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ぽむぽむ さんの方法で、解決しているような気がしますが、ためしに、FormにButton1sとstringGrid1(ColCount は 5、RowCount は 10に設定)を貼り付けて、次のエベントを設定して試してみてください。 procedure TForm1.Button1Click(Sender: TObject); var R,C: Integer; begin Randomize; for R := 1 to 10 do for C := 1 to 4 do begin StringGrid1.Cells[C, R] := intToStr(Random(5)); end; end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin if gdFixed in State then Exit; // 1 が A列 のセル // 2 が B列 のセル if StringGrid1.Cells[1, ARow] <> StringGrid1.Cells[2, ARow] then begin StringGrid1.Canvas.Brush.Color := clRed; StringGrid1.Canvas.FillRect(Rect); StringGrid1.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, StringGrid1.Cells[ACol, ARow]); end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.