delphi checklistbox用法


本文整理自网络,侵删。

 在Delphi中checklistbox中高亮选中(不论是否Checked)能够进行操作么?删除,上下移动等等

删除:CheckListBox.DeleteSelected; 
上下移: CheckListBox.Items.Move 


删除用 
CheckListBox1.Items.Delete(Index); 

上下移动用 
CheckListBox1.Items.Move(CurrentIndex,NewIndex);

//在项目中添加字符串(子项目的最后一位接着添加)
      CheckListBox1.Items.Add(edit1.Text); 

//全选 高亮选中Selected
     CheckListBox1.MultiSelect := True;
     CheckListBox1.SelectAll;

//全选 Checked All
 procedure TForm1.Button11Click(Sender: TObject);
 var i :integer;
 begin
  for i := 0 to CheckListBox1.Items.Count - 1 do  
    begin
      CheckListBox1.Checked[i] := True;//反选设置为False
    end;
 end;

//让第n行被高亮选中
 CheckListBox1.Selected[1]:=true;//第2行

//取消高亮选中
  CheckListBox1.ClearSelection;

//第3行的项目灰色不可用
 CheckListBox1.ItemEnabled[2] := False;//True可用

//删除高亮选中的项目,(只管高亮选中就会被删除,和checked是否无关)
        CheckListBox1.DeleteSelected;//删除选中项目,即使该给项目 没勾上也会被删除

//删除已勾选的中项目
procedure TForm1.Button5Click(Sender: TObject);
var i : integer;
begin
 for i := CheckListBox1.Items.Count-1 downto 0 do  //从后面往前面删
   begin
   if CheckListBox1.Checked[i] then
      begin
         CheckListBox1.Items.Delete(i);
      end;
   end;
end;

//清空项目
  CheckListBox1.Items.Clear; 

//将CheckListBox1的全部添加到CheckListBox2的Items中
procedure TForm1.Button1Click(Sender: TObject);
var
 i:Integer;
begin
 CheckListBox2.Items.Clear;
 for i := CheckListBox1.Items.Count - 1 downto 0 do
   begin
      CheckListBox2.Items.Add(CheckListBox1.Items[i]);
   end;
end;

相关阅读 >>

Delphi 比较两个日期是否大于n天

Delphi获取 斐波那契数列 的函数

Delphi udl文件创建

获取网络日期

Delphi idhttp封装得post get函数

Delphi listview中加载图片

Delphi xe8 androdi利用httpclient实现的一个app自动更新组件

Delphi date 返回当前的日期

Delphi access 数据库压缩

Delphi android下拉刷新

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...