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;

原文地址:https://www.cnblogs.com/jijm123/p/10436399.html

时间: 2024-08-01 02:20:22

delphi checklistbox用法的相关文章

delphi TStringList 用法详解

delphi TStringList 用法详解. TStringList 常用方法与属性 : var List: TStringList; i: Integer; begin List := TStringList.Create; List.Add('Strings1'); {添加} List.Add('Strings2'); List.Exchange(0,1); {置换} List.Insert(0,'Strings3'); {插入} i := List.IndexOf('Strings1'

Delphi TStringHelper用法详解

Delphi TStringHelper用法详解 (2013-08-27 22:45:42) 转载▼ 标签: delphi_xe5 it 分类: Delphi Delphi XE4的TStringHelper,对操作字符串进一步带来更多的方法,使用这些方法才可以实现跨平台的代码. System.SysUtils.TStringHelper 大小写转换:-------------------------------------------------------------------------

Delphi IDHTTP用法详解

[delphi] view plaincopyprint? 一.IDHTTP的基本用法 IDHttp和WebBrowser一样,都可以实现抓取远端网页的功能,但是http方式更快.更节约资源,缺点是需要手动维护cook,连接等 IDHttp的创建,需要引入IDHttp procedure InitHttp(); begin http := TIdHTTP.Create(nil); http.ReadTimeout := 30000; http.OnRedirect := OnRedirect;

delphi json用法

最近接触到json,开始还有点抵触,用多了感觉蛮好玩的,特别是里面什么都可以放,整形I,数组A,对象O,布尔型B等等,而且delphi用起来也很方便,可以直接放文本,当变量,里面的值也可以随时改变,真的太方便了.取值时,也是一层一层的取,若前面都一样可以用with...do...去掉不要的层级.需要注意的是大小写取值时要区分.用法:uses Superobject, Sperjsondelphi里有json单元. procedure TForm2.SuperObjectClick(Sender:

delphi CxGrid用法总结(63问)

1. 去掉cxGrid中台头的Box 解决:在tableview1的optionsview的groupbybox=false; ***************************************************************************** 2.统计功能 解决:(1) tableview tableview1的optionsviewfooter=ture 然后在cxGRid1的customize..中的summary 的footer.add需要合计的列k

delphi CXGRID用法 (取行、列值;定位选中某行等等)

CXGRID用法 (取行.列值:定位选中某行等等) Delphi Cxgrid获取选中行列,排序规则,当前正在编辑的单元格内的值 cxGrid1DBTableView1.Controller.FocusedRowIndex 当前行号 cxGrid1DBTableView1.Controller.FocusedRow 当前行 cxGrid1DBTableView1.Controller.FocusedColumn 当前列 cxGrid1DBTableView1.Controller.Focused

Delphi THashedStringList用法

Delphi中的THashedStringList对象 Delphi在在IniFiles 单元中定义了THashedStringList类: THashedStringList = class(TStringList) private     FValueHash: TStringHash; FNameHash: TStringHash; FValueHashValid: Boolean; FNameHashValid: Boolean; procedure UpdateValueHash; p

delphi 快捷键用法

1. 窗体上全局 快捷键,首先设置keyprivew 属性为true. procedure TFMzcfLr.FormKeyDown(Sender : TObject; var Key : Word; Shift : TShiftState); begin if Key = 13 then //当按下回车时 begin if ActiveControl is TStringGrid then Exit; if ActiveControl is TDBGrid then Exit; if Acti

delphi assignfile用法

1.文本文件新建和读取使用 在窗体放一个按钮,点击输入 procedure TForm1.Button1Click(Sender: TObject);varbat : textfile;beginassignfile(bat, 'c:\123.txt'); //新建并打开文件rewrite(bat); //Rewrite 过程能创建一个新文件并打开它:使用Reset 打开的                         //文本文件是只读的,使用Rewrite 和Append 打开的文本文件只