Q&A

  • StringGrid 에서 셀 병합하는 코딩을 가르쳐 주십시요..
Fixed 된 셀을 병합하여 사용하고 싶은데..

DB Grid말고..StringGrid에 관한 로직은 없는건가요??

한개의 자료에 있던데..정확하게 몰라서..

조금 쉽게 설명해 주시면 감사하겠습니다..ㅠㅠ

-------------------------------------------------------
                      |                       |                    |
------------------------------------------------------
            |         |           |          |          |         |
-------------------------------------------------------

=> 위와 같은 결과를 얻고 싶습니다.. 참고로 델파이5를 사용합니다..
              
4  COMMENTS
  • Profile
    최용일 2009.02.26 19:32
    몇마디로 쉽게 설명할 수 있는 내용은 아니네요...
    TMS의 AdvStringGrid, devExpress의 QuantumGrid같이 병합기능이 들어간 써드파티 컴포넌트를 이용하시는 것이 좋을것같네요...

    아래 링크 참조하세요.
    http://delphi.about.com/od/vclusing/l/aa072203c.htm
  • Profile
    최신욱 2009.02.27 01:27
    고맙습니다..^^

    다음에도 좋은 정보 부탁드립니다..^^
  • Profile
    마이 2009.03.02 02:56
    {
    StringGrid1.ColCount:=7;
    StringGrid1.RowCount:=3;
    StringGrid1.Ctl3d:=False;
    StringGrid1.Cells[0,0] := 'Title1';
    StringGrid1.Cells[1,0] := 'Title2';
    StringGrid1.Cells[2,1] := 'Sub1';
    StringGrid1.Cells[3,1] := 'Sub2';
    StringGrid1.Cells[4,1] := 'Sub3';
    StringGrid1.Cells[5,1] := 'Sub4';
    StringGrid1.Cells[6,0] := 'Title3';
    StringGrid1.ColWidths[0] := 100;
    StringGrid1.ColWidths[1] := 100;
    StringGrid1.ColWidths[2] := 100;
    StringGrid1.ColWidths[3] := 100;
    StringGrid1.ColWidths[4] := 100;
    StringGrid1.ColWidths[5] := 100;
    StringGrid1.ColWidths[6] := 100;
    }
    procedure MergeCells(Sender:TObject; ALeftCol,ATopRow,ARightCol,ABottomRow:integer; ACaption:string);
    var
    lRECT1,lRECT2 : TRect;
    begin
    with Sender as TStringGrid do
    begin
    if (ALeftCol>=LeftCol+VisibleColCount) then Exit;
    if (ATopRow>=TopRow+VisibleRowCount) then Exit;

    if (ALeftCol>=FixedCols) and (ALeftCol if (ATopRow >=FixedRows) and (ATopRow
    if (ARightCol>=LeftCol+VisibleColCount) then ARightCol:=LeftCol+VisibleColCount;
    if (ALeftCol>ARightCol) then Exit;
    if (ATopRow>ABottomRow) then Exit;

    lRECT1:=CellRect(ALeftCol,ATopRow);
    lRECT2:=CellRect(ARightCol,ABottomRow);
    InFlateRect(lRECT1,1,1);
    InFlateRect(lRECT2,1,1);
    lRECT1.Right :=lRECT2.Right - 1;
    lRECT1.Bottom:=lRECT2.Bottom - 1;

    lRECT1.Top := lRECT1.Top + 1;
    lRECT1.Left := lRECT1.Left + 1;

    Canvas.Brush.Color := clBtnFace;
    Canvas.FillRect(lRECT1);
    Canvas.RectAngle(lRECT1);
    if lRECT1.Bottom-lRECT1.TOP <= 1 then
    Exit;

    Canvas.Font.Color := clBlack;
    Canvas.TextOut(lRECT1.Left+(lRECT1.Right-lRECT1.Left-Canvas.TextWidth(ACaption)) div 2
    ,lRECT1.Top +(lRECT1.Bottom-lRECT1.Top-Canvas.TextHeight(ACaption)) div 2
    ,ACaption);
    end;
    end;


    procedure TfrmMain.StringGrid1DrawCell(Sender: TObject; ACol,
    ARow: Integer; Rect: TRect; State: TGridDrawState);
    begin
    MergeCells(Sender,0,0,0,1,'Title1');
    MergeCells(Sender,1,0,1,1,'Title2');
    MergeCells(Sender,2,0,5,0,'Title3');
    MergeCells(Sender,6,0,6,1,'Title4');
    end;
  • Profile
    최신욱 2009.03.04 22:40
    정말 고맙습니다..ㅠㅠ

    유용한 정보 잘이용할께염^^