掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
StringGridで選択した行に同期して固定セルの色を変えたい (ID:47754)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
タイトルの通りStringGridで選択した行に同期して固定セルの行の色を変えたいのですが 以下のソースでStringGrid1Clickの中で強制的にStringGrid1.Refreshしないと カーソルと同時に固定セルの色が変わりません。 StringGrid1.Refreshをしますと画面がチカチカしますので StringGrid1.Refreshを使わなくてもいい方法は無いでしょうか。 よろしくご教授お願いします。 尚、環境は Win8.1+Delphi6.0 です。 //------------------------------------------------- 〜略〜 procedure TForm1.FormShow(Sender: TObject); begin StringGrid1.Options := StringGrid1.Options + [goRowSelect] - [goEditing] - [goRangeSelect]; end; procedure TForm1.StringGrid1Click(Sender: TObject); begin StringGrid1.Refresh; // *** end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var s1: string; SRect: TGridRect; iOptions: Integer; begin SRect := TStringGrid(sender).Selection ; //------------------------------------------------ // 固定部 if (gdFixed In State) then begin with TStringGrid(sender).Canvas do begin if (Acol>=0) and (ARow>=SRect.Top) and (ARow<=SRect.Bottom) then begin Brush.Color := clAqua; FillRect(Rect); end; end; end; //------------------------------------------------ // 可変部 / 一行全部色変更 if (Acol>=0) and (ARow>=SRect.Top) and (ARow<=SRect.Bottom) then begin with TStringGrid(sender).Canvas do begin if (Acol>=1) then begin s1 := TStringGrid(sender).Cells[ACol, ARow]; Brush.Color := clAqua ; FillRect(Rect); iOptions := DT_SINGLELINE or DT_LEFT or DT_VCENTER ; DrawTextEx(TStringGrid(sender).Canvas.Handle, PChar(s1), Length(s1), Rect, iOptions, nil); end; end; end; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.