Q&A

  • StringGrid 에서 Cell 병합이 가능할까요?
스트링그리드에서 셀을 병합해서 사용할려고 하는데 잘 안되는군요

그래서 컴포넌트를 새로 만들려고 하는데 대략 가능한 방법을 아시면

조언부탁합니다.

1  COMMENTS
  • Profile
    bluesky 2000.11.24 18:27
    김기용 wrote:

    > 스트링그리드에서 셀을 병합해서 사용할려고 하는데 잘 안되는군요

    > 그래서 컴포넌트를 새로 만들려고 하는데 대략 가능한 방법을 아시면

    > 조언부탁합니다.



    셀을 병합한것처럼 보이게 하는것이거든요..

    스트링그리드의 DrawCell Event에 다음을 써 보세여..



    procedure TForm1.StringGrid3DrawCell(Sender: TObject; ACol, ARow: Integer;

    Rect: TRect; State: TGridDrawState);

    var

    i, x, y: Integer;

    begin

    If gdFixed In State Then Exit;

    If ARow > 1 Then Exit;



    with Sender as TStringGrid do

    begin

    If aCol < Pred(ColCount) Then

    Rect.Right := Rect.Right + GridlineWidth;

    y:= Rect.Top + 2;

    x:= Rect.Left + 2;

    for i:= 1 to aCol-1 do

    x:= x - ColWidths[i] - GridlineWidth;



    Canvas.Brush.Color := $7FFFFF;

    Canvas.Brush.Style := bsSolid;

    Canvas.FillRect( Rect );



    Canvas.TextRect( Rect, x, y, Cells[1,1] );

    end;

    end;