listdlg

1:问题引入:
在某些场合,需要进行用户交互,比如给定一些选项,让用户进行选择,此时,listdlg就是一个不错的选择,比如如下的一个例子:
listdlg - Free thought - Free Thought
 列出本文件夹下的所有文件,双击时会返回选择的文件的索引。
2:listdlg函数介绍
输入是参数对,输出(当双击或者敲击回车)是列表项的索引
 Parameter Description
 'ListString' cell array of strings for the list box.
  'SelectionMode'  string; can be 'single' or 'multiple'; defaults to'multiple'.
 'ListSize' [width height] of listbox in pixels; defaults  to [160 300].
 'InitialValue'
 vector of indices of which items of the list box
 are initially selected; defaults to the first item.
  'Name'   String for the figure's title; defaults to ''.
  'PromptString'
  string matrix or cell array of strings which appears
as text above the list box; defaults to {}.
  'OKString'  string for the OK button; defaults to 'OK'.
  'CancelString'  string for the Cancel button; defaults to 'Cancel'.
  
3:例子
在进行批量处理的时候,我要选择需要处理的是bmp或者其他类型的图片,此时,最好是先用户进行一次选择,代码如下:
str = {'jpg','png','bmp'};
   [s,v] = listdlg('PromptString','Double click to choose the image format.',...
               'SelectionMode','single','ListString',str,...
               'Name','Select a image format','InitialValue',1,...
               'ListSize',[230,100]);
   imgExt = str{s};
执行效果如下:
listdlg - Free thought - Free Thought
 当双击(或者回车)jpg,png或者bmp中的一个之后,返回值imgExt即为选中的值。

转载于:https://www.cnblogs.com/DeepVL/p/4085250.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值