TListView 里面设置的是 viewstyle:=vsReport;格式,怎么样实现里面的记录可以上下拖动
解决方案 »
- 菜鳥求助,如何實現dELPHI中的label邊框顯示以及顏色,在線等
- sz_haitao 进来一下
- 求<神州数码有限公司>招聘笔试题
- 求教 救助 求助! ASP页面与DELPHI WIN32交互
- 在delphi中定义一个类时,如何声明一个类变量成员?在线等待。。。。
- 一个关于excel的简单问题,在线等待!
- 怎样做成公用函数?
- 如何用DELPHI设计异形窗口
- 给我一个将表(.db)转化成excel格式的例子,包含设置字体和表头,合计功能。谢谢。
- 求<<Delphi5 开发人员指南>>之配套光盘
- (up加分)sqlserver备份与恢复(从服务器备份到本地,从本地恢复到服务器)
- 如何将dbgrideh中的option中的属性值设为false?
Y: Integer; State: TDragState; var Accept: Boolean);
begin
if (Source is TListView)and(TmpListItem<>nil) then
begin
Accept:=(ListView1.GetItemAt(X,Y)<>TmpListItem);
end;
end;procedure TFrmMain.ListView1EndDrag(Sender, Target: TObject; X,
Y: Integer);
var
T2:TListItem;
begin
T2:=ListView1.GetItemAt(X,Y);
if (Target is TListView)and(TmpListItem<>nil)and(T2<>TmpListItem) then
begin
if T2.Index<TmpListItem.Index then
T2:=ListView1.Items.Insert(T2.Index)
else T2:=ListView1.Items.Insert(T2.Index+1);
T2.Caption:=TmpListItem.Caption;
// T2.ImageIndex:=TmpListItem.ImageIndex;
// 关于这个Item的处理都写在这里
TmpListItem.Delete;
TmpListItem:=nil;
ListView1.Refresh;
end;
end;procedure TFrmMain.ListView1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if not ListView1.Dragging then
begin
TmpListItem:=ListView1.GetItemAt(X,Y);
ListView1.BeginDrag(True);
end;
end;
down: boolean = False;
index: integer = -1;implementation{$R *.dfm}procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
index := ListView1.ItemIndex;
if index < 0 then Exit;
down := True;
end;procedure TForm1.ListView1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
cap: string;
tmp: TStringList;
begin
tmp := TStringList.Create;;
if down then
begin
if (ListView1.ItemIndex >= 0) and (index >= 0) and (ListView1.ItemIndex <> index) then
begin
// 交换
cap := ListView1.Items[index].Caption;
tmp.Assign(ListView1.Items[index].SubItems);
ListView1.Items[index].Caption := ListView1.Selected.Caption;
ListView1.Items[index].SubItems.Assign(ListView1.Selected.SubItems);
ListView1.Selected.Caption := cap;
ListView1.Selected.SubItems.Assign(tmp);
end;
end;
tmp.Free;
end;
已经有人说了的_____________________
http://lysoft.7u7.net