掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
stringgridの結合後で横にスクロールすると (ID:40646)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
現在stringgridの結合で表示させたいと思って 過去の質問などを読んでいますが 横のカラムを結合して スクロールさせると 結合したセルが縦のカラムにかぶって表示していまい カラムが見えなくなる現象が起こってしまいます。 かなり変則的なセルの結合をしています。 スクロールした時に 横のカラムが縦にかぶらないようにするには どうすればいいでしょうか? 以下プログラムの一部です procedure TForm1.FormCreate(Sender: TObject); var i : Integer; val: integer; begin StringGrid1.ColCount := 52; StringGrid1.Cells[0,0]:='ID'; StringGrid1.Cells[0,1]:='ID'; StringGrid1.Cells[0,2]:='ID'; StringGrid1.Cells[1,0]:='名前'; StringGrid1.Cells[1,1]:='名前'; StringGrid1.Cells[1,2]:='名前'; StringGrid1.Cells[2,0]:='年齢'; StringGrid1.Cells[2,1]:='年齢'; StringGrid1.Cells[2,2]:='年齢'; StringGrid1.Cells[3,0]:='性別'; StringGrid1.Cells[3,1]:='性別'; StringGrid1.Cells[3,2]:='性別'; for I := 4 to 51 do begin StringGrid1.Cells[I,0]:='2011/04/19'; StringGrid1.Cells[I,1]:='OK'; if I mod 2 = 1 then begin StringGrid1.Cells[I,2]:= 'OK'; end else begin StringGrid1.Cells[I,2]:= 'NG'; end; end; StringGrid1.DefaultDrawing := False; end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var col1,col2 :Integer; begin with StringGrid1 do begin DefaultDrawing:=False; if (ARow <= 2)and(ACol >= 4)and(gdFixed in State) then begin case ACol mod 2 of 0 : Rect.Right := Rect.Right + ColWidths[ACol+1]; 1 : Rect.Left := Rect.Left - ColWidths[ACol-1] - 1; end; end else if (ACol <= 3)and(gdFixed in State)then begin case ARow of 0 : Rect.Bottom := Rect.Bottom + RowHeights[1]; 2 : Rect.Top := Rect.Top - RowHeights[1]- RowHeights[0] - 1; end; end; if ((gdSelected in State) )then begin Canvas.Brush.Color := clHotLight; Canvas.Font.Color := clWhite; end else begin if (gdFixed in State) then begin Canvas.Brush.Color := clBtnFace; end else begin Canvas.Brush.Color := clWindow; Canvas.Font.Color := clBlack; end; end; Canvas.FillRect(Rect); DrawEdge(Canvas.Handle, Rect, BDR_RAISEDINNER, BF_RECT); DrawText(Canvas.Handle, PChar(Cells[ACol, ARow]), -1, Rect, DT_SINGLELINE or DT_VCENTER or DT_CENTER); end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.