仅将选中的TListBox.Items复制到TStringList [英] Copy only checked TListBox.Items to a TStringList

查看:66
本文介绍了仅将选中的TListBox.Items复制到TStringList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将列表框的所有项目(字符串)复制到字符串列表对象?所有帮助源仅显示如何将字符串列表复制到listbox.items,我想采用其他方法.怎么做?

另外,如何仅将选定的(选中的项目)复制到StringList?

How do I copy all the items (strings) of listbox to a stringlist object? All help sources only show how to copy a stringlist to a listbox.items, I want to do it the other way around. How is that done?

As an addition, how can only the selected (checked items) be copied to a StringList?

推荐答案

for i := 0 to CheckListBox1.Items.Count - 1 do
  begin
    if CheckListBox1.Checked[i] then
    begin
      sl.Add(CheckListBox1.Items.Strings[i]);
    end;
  end;



您可以使用Selected而不是Checked 在列表框中获取选定的项目.

祝你好运!



You can use Selected instead of Checked to get the selected items in a listbox.

Good luck!


这篇关于仅将选中的TListBox.Items复制到TStringList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆