Q&A

  • stringgrid에서 한 라인(Row)을 삭제
stringgrid에서 한 라인(Row)을 삭제



stringgrid에서 한 라인(Row)을 삭제하려고 합니다



어떻게 해야하나요?



column은 2입니다.

1  COMMENTS
  • Profile
    김태균 1999.06.10 18:23
    정청환 께서 말씀하시기를...

    > stringgrid에서 한 라인(Row)을 삭제

    >

    > stringgrid에서 한 라인(Row)을 삭제하려고 합니다

    >

    > 어떻게 해야하나요?

    >

    > column은 2입니다.



    음... 제가 실제 프로젝트에 썼던 건데

    오래 된거라서 쓸만할지 모르겠네요.



    procedure TInsertForm.StringGrid11KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

    Var i,Stat : integer;

    begin

    if IntToStr(Ord(Hi(Key)))+IntToStr(Ord(Lo(Key))) = '046' then {Delete key누르면 삭제}

    begin

    if stringgrid11.Rowcount = 2 then

    begin

    stringgrid11.Cells[1,1] := '';

    stringgrid11.Cells[2,1] := '';

    stringgrid11.Cells[3,1] := '';

    stringgrid11.Cells[4,1] := '';

    end

    else

    begin

    for i := stringgrid11.row to (stringgrid11.Rowcount - 1) do

    begin

    stringgrid11.Cells[1,i] := stringgrid11.Cells[1,i+1];

    stringgrid11.Cells[2,i] := stringgrid11.Cells[2,i+1];

    stringgrid11.Cells[3,i] := stringgrid11.Cells[3,i+1];

    stringgrid11.Cells[4,i] := stringgrid11.Cells[4,i+1];

    end;

    stringgrid11.RowCount := stringgrid11.Row ;

    end;

    end;