我在界面上放了俩个image,怎么样从FileListBox1中显示两张不同的图片分别到image1和image2?

解决方案 »

  1.   

    FileListBox1,显示文件在你指定的路径里你先保存你的东西,到你的工程文件下
      

  2.   

    我现在是:两个IMAGE显示的是相同的内容,代码:
    Image1.Picture.LoadFromFile(FileListBox1.Filename);  Image2.Picture.LoadFromFile(FileListBox1.Filename);
    怎么样添加 修改那?
      

  3.   

    楼主描述的不清楚。
    if image1有图片 and image2没图片 then 显示到image2?
    if image1有图片 and image2有图片 then 显示到iamge1?清空image2?
    ...........
      

  4.   

    if image1有图片 and image2没图片 then 显示到image2
    if image1有图片 and image2有图片 then 显示到iamge1,保留image2
      

  5.   

    我这里在网上看到用控件数组来显示的代码,我调试一直有问题。在:
          Images.Picture.LoadFromFile(Form1.FileListBox1.Items[startindex+i]);//读入图像
          Images.Show;//显示图像
          Labels.Caption:=Form1.FileListBox1.Items[startindex+i];//
    在Images出显示:
    [Error] Unit1.pas(44): Record, object or class type required那位大哥帮忙看看
    原代码::
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls,FileCtrl, StdCtrls;type
      TForm1 = class(TForm)
        DriveComboBox1: TDriveComboBox;
        FileListBox1: TFileListBox;
        DirectoryListBox1: TDirectoryListBox;
        procedure FormCreate(Sender: TObject);
        procedure DirectoryListBox1Change(Sender: TObject);
        procedure FileListBox1Change(Sender: TObject);
      private
        { Private declarations }
      public
           index:integer;    { Public declarations }
      end;var
      Form1: TForm1;
      panels: array[0..15] of TPanel;//定义控件数组
      images: array[0..15] of TImage;
      Labels: array[0..15] of Tlabel;
      startindex:integer;//显示第一个图像的标志
      imageflag:Boolean;implementation{$R *.dfm}procedure viewpicture;
    var i,j:integer;
    begin
      j:=Form1.FilelistBox1.items.Count-startindex;
        if j>16 then j:=16;
         for i:=0 to j-1 do
          Begin
             Images.Picture.LoadFromFile(Form1.FileListBox1.Items[startindex+i]);//读入图像
             Images.Show;//显示图像
             Labels.Caption:=Form1.FileListBox1.Items[startindex+i];//显示文件名
          end;
          for i:=j to 15 do
          begin
           Images.Hide;//隐藏显示不下的图像
           Labels.Caption:='';
         end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    var i:integer;
    begin
      startindex:=0;
      For i:=0 to 15 Do
      begin
        panels:=TPanel.Create(self);//动态建立Panel组件
        panels.Parent:=self;
       panels.Left:=1+(i mod 4)*100;//设置15个panel组件的属性
       panels.Top:=10+(i div 4)*124;
       panels.Width:=100;
       panels.Height:=100;
       panels.BevelInner:=bvLowered;
       panels.BevelOuter:=bvRaised;
       panels.Caption:='';
       labels:=Tlabel.Create(self);//动态建立15个Label组件用于显示图像的文件名
      labels.Parent:=self;
      labels.Left:=5+(i mod 4)*100;//分别设置15个Label组件的属性
      labels.Top:=115+(i div 4 )*124;
      labels.Width:=50;
      labels.Height:=17;
      labels.Caption:='';
      images:=TImage.Create(self);//动态建立15个Label组件用于显示图像
      images.Parent:=panels;
      images.AutoSize:=True;//设置各Image组件的相关属性
       images.Align:=alClient;
       images.Center:=True;
       images.Stretch:=True;
       end;
        if FileListBox1.Items.Count<>0 then//如果 该目录中有图像文件
         begin
           viewpicture;//显示图像
          imageflag:=True;//有图像标志设为真
        end
        else imageflag:=False;//设为无图状态
       end;
    procedure TForm1.DirectoryListBox1Change(Sender: TObject);
    begin
      startindex:=0;
    end;procedure TForm1.FileListBox1Change(Sender: TObject);
    begin
        startindex:=FileListBox1.itemindex;
           if startindex=-1 then startindex:=0;
           index:=FileListBox1.items.Count;//获得图像文件总数
           if FileListBox1.items.Count=0 then //无图
           begin
              if imageflag=False then exit;
              viewpicture;
              imageflag:=False
           end
           else begin
           imageflag:=True;
            viewpicture;
         end;end;end.