TListView 里面设置的是 viewstyle:=vsReport;格式,怎么样实现里面的记录可以上下拖动
解决方案 »
- 为什么不能触发dbgrid的onkeypress事件(ADOQUERY中指针已经变化,但DBGRID显示的内容却不变)?
- DataModule 出错
- 我回答问题接了几十分,怎么没有加到我的可用分里面?
- 请问Delphi中什么时间函数的计时能达到微秒级,如果没有毫秒级的也行
- 窗体移动的问题
- 学习DELPHI的一些想法。
- 向高手请教,delphi6怎样把主表和细表的数据同时都显示在一个dbgrideh中?
- 如何解决报表中多表查询一条记录对多条记录的问题
- 哪有通过oicq得到其它人ip的软件(非常的感谢)
- 使用类似delphi里数据感知组件是否有违面向对象里封装的特性
- (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