Ver Mensaje Individual
  #4  
Antiguo 08-06-2024
Avatar de Casimiro Noteví
Casimiro Noteví Casimiro Noteví is online now
Merodeador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.669
Reputación: 10
Casimiro Noteví Tiene un aura espectacularCasimiro Noteví Tiene un aura espectacular
Viene a ser lo mismo, pasar datos a un listbox, aquí tienes un ejemplo.


Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    ButtonLoad: TButton;
    ButtonSave: TButton;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    procedure ButtonLoadClick(Sender: TObject);
    procedure ButtonSaveClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ButtonLoadClick(Sender: TObject);
var
  StringList: TStringList;
begin
  if OpenDialog1.Execute then
  begin
    StringList := TStringList.Create;
    try
      StringList.LoadFromFile(OpenDialog1.FileName);
      ListBox1.Items.Assign(StringList);
    finally
      StringList.Free;
    end;
  end;
end;

procedure TForm1.ButtonSaveClick(Sender: TObject);
var
  StringList: TStringList;
begin
  if SaveDialog1.Execute then
  begin
    StringList := TStringList.Create;
    try
      StringList.Assign(ListBox1.Items);
      StringList.SaveToFile(SaveDialog1.FileName);
    finally
      StringList.Free;
    end;
  end;
end;

end.
Responder Con Cita