Q&A

  • 리스트 뷰


오늘 첨 리스트 뷰를 써보려 하는데 잘 안되네여



1|2001/10/19|BABO|ANGEL|

이런 데이터를 잘라서



-----------------------

DATE | TYPE | NAME |

-----------------------

2001/..|BABO |ANGEL |

------------------------

.....





이런 모양으로 만들려고 합니다.



아래 코드를 실행시켰더니,

으이궁..





-----------------------

DATE | TYPE | NAME |

-----------------------

| 2001/..| |

BABO

ANGEL

------------------------

.....



이렇게 나타나네여.. 왜 그런거져.. ? ㅜ.ㅠ

주르륵...



procedure TForm1.ShowLogList(fname : String);

var

F : TextFile;

temp : String;

buf : String;

begin

AssignFile(F, fname);

Reset(F);

while not Eof(F) do begin

readln(F, Buf);

temp := Copy(Buf, 1, Pos('|', Buf)-1); delete(Buf, 1, 2);

if strToInt(temp) = 1 then

begin

temp := Copy(Buf, 1, Pos('|', Buf)-1);

delete(Buf, 1, Pos('|', Buf)-1); delete(Buf, 1, 1);

showmessage(temp);



ListView1.Items.Add.SubItems.Add(temp);

temp := Copy(Buf, 1, Pos('|', Buf)-1);

delete(Buf, 1, Pos('|', Buf)-1); delete(Buf, 1, 1);

ListView1.Items.Add.SubItems.Add(temp);

end;

end;

CloseFile(F);

end;

1  COMMENTS
  • Profile
    조건일 2001.10.20 00:48


    우선~ 리스트뷰 작동원리까지는 아니더라도 문법구성 정도는 정확하게 이해 하셔야 겠네요...

    여기 글에 보면 제가 올린 글이나 다른 고수분들께서 올린 글들을 검색하여

    사용방법을 학습하시구여....



    님께서 질문하신 방법을 나름대로 간단하게 해결하는 꽁수를 함 생각해 봤슴다...

    (넘 어려운가여?, 잘모르겠으면 걍 배끼세여....)



    procedure TForm1.Button1Click(Sender: TObject);

    var F : TextFile;

    Buf: String;

    StrLst : TStringList;

    begin

    AssignFile(F, fname);

    Reset(F);

    while not Eof(F) do

    begin

    readln(F, Buf);

    StrLst := TStringList.Create;

    StrLst.CommaText := StringReplace(Buf,'|',',',[rfReplaceAll]);



    with ListView1.Items.Add do

    begin

    Caption :=StrLst[0];

    StrLst.Delete(0);

    SubItems.CommaText := StrLst.CommaText;

    end; //with

    StrLst.Clear;

    StrLst.destroy;

    end; //while

    CloseFile(F);

    end;



    즐델하셔염.......



    초보예여 wrote:

    >

    > 오늘 첨 리스트 뷰를 써보려 하는데 잘 안되네여

    >

    > 1|2001/10/19|BABO|ANGEL|

    > 이런 데이터를 잘라서

    >

    > -----------------------

    > DATE | TYPE | NAME |

    > -----------------------

    > 2001/..|BABO |ANGEL |

    > ------------------------

    > .....

    >

    >

    > 이런 모양으로 만들려고 합니다.

    >

    > 아래 코드를 실행시켰더니,

    > 으이궁..

    >

    >

    > -----------------------

    > DATE | TYPE | NAME |

    > -----------------------

    > | 2001/..| |

    > BABO

    > ANGEL

    > ------------------------

    > .....

    >

    > 이렇게 나타나네여.. 왜 그런거져.. ? ㅜ.ㅠ

    > 주르륵...

    >

    > procedure TForm1.ShowLogList(fname : String);

    > var

    > F : TextFile;

    > temp : String;

    > buf : String;

    > begin

    > AssignFile(F, fname);

    > Reset(F);

    > while not Eof(F) do begin

    > readln(F, Buf);

    > temp := Copy(Buf, 1, Pos('|', Buf)-1); delete(Buf, 1, 2);

    > if strToInt(temp) = 1 then

    > begin

    > temp := Copy(Buf, 1, Pos('|', Buf)-1);

    > delete(Buf, 1, Pos('|', Buf)-1); delete(Buf, 1, 1);

    > showmessage(temp);

    >

    > ListView1.Items.Add.SubItems.Add(temp);

    > temp := Copy(Buf, 1, Pos('|', Buf)-1);

    > delete(Buf, 1, Pos('|', Buf)-1); delete(Buf, 1, 1);

    > ListView1.Items.Add.SubItems.Add(temp);

    > end;

    > end;

    > CloseFile(F);

    > end;