如题,放一个按钮,使得CheckListBox里面选择的Item能够向上或者向下移动?
解决方案 »
- 请问有谁用Delphi7.0+SQL Server2000设计过“学生学籍管理系统”?
- 关于窗体继承的问题
- 大家看看我写的恢复数据库的sql语句有什么问题,总是出错
- .dcu是什么文件?有方法查看它的源代码吗?
- 如何从远程服务器下载文件到本机
- 三层中如何从客户端将图片加入到Sql Server中的image字段中....?
- fastreport中如何打印WORD文档?
- 谁拿事务没办法,我行!
- 高分问题
- 一个初级问题:像DELPHI的菜单是如何做的,前面的"|",可以移动
- 我没有delpi6.0和Spcomm控件 安装光盘?求助!!(谢谢各位,能快点告诉我吗?)
- [Fatal Error] Project1.dpr(1): File not found: 'System.pas'如何解决?
procedure TForm1.Button1Click(Sender: TObject);
begin
//上移操作
if CheckListBox1.ItemIndex > 0 then
CheckListBox1.Items.Move(CheckListBox1.ItemIndex, CheckListBox1.ItemIndex - 1);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//下移操作
if CheckListBox1.ItemIndex = -1 then Exit;
if CheckListBox1.ItemIndex < CheckListBox1.Items.Count - 1 then
CheckListBox1.Items.Move(CheckListBox1.ItemIndex, CheckListBox1.ItemIndex + 1);end;
var s:string;
ck1,ck2:boolean;
i:integer;
begin
i:=checklistbox1.ItemIndex;
if i<CheckListBox1.Count-1 then
begin
ck1:=CheckListBox1.Checked[i];
ck2:=CheckListBox1.Checked[i+1];
s:=CheckListBox1.Items[i];
CheckListBox1.Items[i]:=CheckListBox1.Items[i+1];
CheckListBox1.Items[i+1]:=s;
CheckListBox1.Checked[i]:=ck2;
CheckListBox1.Checked[i+1]:=ck1;
CheckListBox1.ItemIndex:=i+1;
end;
end;
var
iCurrentIndex: Integer;
begin
//上移操作 if CheckListBox1.ItemIndex > 0 then
begin
iCurrentIndex := CheckListBox1.ItemIndex - 1;
CheckListBox1.Items.Move(CheckListBox1.ItemIndex, CheckListBox1.ItemIndex - 1);
end; CheckListBox1.SetFocus;
CheckListBox1.ItemIndex := iCurrentIndex;
end;procedure TForm1.Button2Click(Sender: TObject);
var
iCurrentIndex: Integer;
begin
//下移操作
if CheckListBox1.ItemIndex = -1 then Exit;
if CheckListBox1.ItemIndex < CheckListBox1.Items.Count - 1 then
begin
iCurrentIndex := CheckListBox1.ItemIndex + 1;
CheckListBox1.Items.Move(CheckListBox1.ItemIndex, iCurrentIndex);
end;
CheckListBox1.SetFocus;
CheckListBox1.ItemIndex := iCurrentIndex;
end;