DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: forget66
今日帖子: 65
在线用户: 14
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 tuesdays (Tuesday) ▲▲▲▲△ -
普通会员
2022/5/9 14:03:10
标题:
TOpenDialog Files怎么让它不排序? 浏览:632
加入我的收藏
楼主: 多选时, 
按先选的文件排前面.
----------------------------------------------
delphi界写python最强, python界写delphi最强. 写自己的代码, 让别人去运行.
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/5/10 8:09:15
1楼: here RAD 11.1, TOpenDialog dont use any sort result!

  // natural ordem on MSExplorer list
  if OpenDialog1.Execute then
    Memo1.Text := OpenDialog1.Files.Text;

 as you know, "Files" is a "TStrings", then you can sort it if you need!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/5/10 8:19:42
2楼: procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then  // MULTI-SELECT
    Memo1.Text := OpenDialog1.Files.Text;
  //
  Memo1.Lines.Add('---- SORTED ----');
  //
  TStringList(OpenDialog1.Files).Sorted := true;
  //
  Memo1.Lines.AddStrings(OpenDialog1.Files);
end;
此帖子包含附件:
PNG 图像
大小:12.9K
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/5/10 8:24:39
3楼: Now if you WANT "controls" the "list-items", then you need do it in 

Vcl.Dialogs.TOpenDialog.OnIncludeItem  event... <---- here!
NOTE: OLD PROBLEM with use this event... dont waste your time!


maybe, in "Vcl.Dialogs.TOpenDialog.OnSelectionChange" event to show on screen!
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
作者:
男 emailx45 (emailx45) ▲▲▲▲△ -
普通会员
2022/5/10 8:30:25
4楼: you can try this:

var
  MyList: TStringList = nil;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    Memo1.Lines.AddStrings(MyList);
end;

procedure TForm1.OpenDialog1SelectionChange(Sender: TObject);
begin
  // you need controls if the file already exists on list....
  //
  // procedure MyListControlIfFileAlreadyExists( MyList...)
  // if (MyList.IndexOf( xxxFileName) = -1) then
  //  ...Add it
  //
  if (TOpenDialog(Sender).Files.Count > 1) then
    MyList.AddStrings(TOpenDialog(Sender).Files)
  else
    MyList.Add(TOpenDialog(Sender).FileName);
end;

initialization

MyList          := TStringList.Create;
//
// Note: Duplicates does nothing if the list is not sorted.
//MyList.Duplicates := TDuplicates.dupIgnore;

finalization

MyList.Free;
----------------------------------------------
The higher the degree, the greater the respect given to the humblest!RAD 11.3
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行109.375毫秒 RSS