刪除: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
procedureTForm1.Button11Click(Sender: TObject);
var i :integer;
begin
for i := 0toCheckListBox1.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;//刪除選中項目,即使該給項目沒勾上也會被刪除
//刪除已勾選的中項目
procedureTForm1.Button5Click(Sender: TObject);
var i :integer;
begin
for i := CheckListBox1.Items.Count-1downto0 do//從后面往前面刪
begin
ifCheckListBox1.Checked[i] then
begin
CheckListBox1.Items.Delete(i);
end;
end;
end;
//清空項目
CheckListBox1.Items.Clear;
//將CheckListBox1的全部添加到CheckListBox2的Items中
procedureTForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin
CheckListBox2.Items.Clear;
for i := CheckListBox1.Items.Count - 1downto0 do
begin
CheckListBox2.Items.Add(CheckListBox1.Items[i]);
end;
end;
愛華網



