Announcement

Collapse
No announcement yet.

Problem mit opendialog

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem mit opendialog

    Hi Leute

    wie kann ich eine textdatei(mit opendialog) in eine Listbox laden.

    if opendialog1.execute then .....

    ich hab mal ein bisschen probiert, hab aber nur sch.... gebaut.
    also muss ich eben im forum posten.

    danke für eure hilfe.
    stefan

  • #2
    Hi,<BR>
    1.) Bei einer Listbox musst du Zeile für Zeile der<BR>
    Textdatei einlesen.
    2.) Nehme wenn möglich ein TMemo.<BR>

    Bsp.für Listbox<BR>
    procedure TForm1.Button1Click(Sender : Tobject);<BR>
    var<BR>
    f : TextFile;<BR>
    s : String;<BR>
    begin<BR>
    if OPenDialog1.Execute then begin<BR>
    ListBox1.Items.Clear;<BR>
    AssigFile(f, OpenDialog1.FileName);<BR>
    Reset(f); // Textdatei öffnen<BR>
    While not eof(f) do begin<BR>
    ReadLn(f,s);<BR>
    ListBox1.Items.Add(s);<BR>
    end;<BR>
    CloseFile(f);<BR>
    end;<BR>
    end;<BR>

    Bsp. für TMemo:<BR>
    procedure TForm1.Button1Click(Sender : Tobject);<BR>
    begin<BR>
    if OPenDialog1.Execute then begin<BR>
    Memo1.Lines.LoadFromFile(OpenDialog1.FileName);<BR >
    end;<BR>
    end;<BR>

    Gruß<BR>
    Matthias<BR&gt

    Comment


    • #3
      dank

      Comment


      • #4
        TListBox.Items ist vom Typ TStrings. Man kann deshalb auch mit der ListBox einfach LoadFromFile() benutzen

        Comment

        Working...
        X