我想把应用服务器上的ListView中数据传到客户端中的ListView中去,定义一个过程不知怎么写(20分)

  • 主题发起人 主题发起人 xbbtzhao
  • 开始时间 开始时间
X

xbbtzhao

Unregistered / Unconfirmed
GUEST, unregistred user!
处么把ListView中的数据写入数组或TStrings,还有处么把数组或TStrings写入ListView?
procedure TDBMLINK.LinkUser(var Link: OleVariant);//怎么写代码
begin

end;
 
问题有进步了!
还有一个问题:我在应用层客一个properyt
function TDBMLINK.Get_LinkUser: OleVariant;//不知选什么类型才能返回ListItems类型
begin
Result:=AppSer.ListView.Items //我要返回的是TListItems类型 ,
end;
提示:Incompatible types: 'OleVariant' and 'TListItems'
 
问题已解决
 
怎么解决的,把代码贴出来,学习学习
 
ListView间传数据
private
v:Variant;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.dfm}
//保存
procedure TForm1.Button1Click(Sender: TObject);
var
MaxR:Integer;
MaxC:Integer;
r:integer;
c:integer;
begin
MaxR:=ListView1.Items.Count;
MaxC:=ListView1.Columns.Count;
v:=vararraycreate([0,MaxR,0,MaxC-1],varVariant);
//保存標題
for c:=0 to ListView1.Columns.Count-1do
begin
v[0,c]:=ListView1.Columns.Items[c].Caption;
end;
//保存數據
for r:=0 to ListView1.Items.Count-1do
begin
v[r+1,0]:=ListView1.Items[r].Caption;
for c:=0 to ListView1.Items[r].SubItems.count-1do
begin
v[r+1,c+1]:=ListView1.Items[r].SubItems.Strings[c];
end;
end;
end;

//恢復
procedure TForm1.Button2Click(Sender: TObject);
var
MaxR:Integer;
MaxC:Integer;
r:integer;
c:integer;
s:string;
begin
if not VarIsArray(v) then
Exit;
//恢復標題
r:=VarArrayLowBound(v,1);
for c:=VarArrayLowBound(v,2) to VarArrayHighBound(v,2)do
with ListView2.Columns.Adddo
Caption:=v[r,c];
//恢復數據
for r:=VarArrayLowBound(v,1)+1 to VarArrayHighBound(v,1)do
begin
with ListView2.Items.Adddo
begin
caption:=v[r,VarArrayLowBound(v,2)];
for c:=VarArrayLowBound(v,2)+1 to VarArrayHighBound(v,2)do
SubItems.Add(v[r,c]);
end;
end;
end;
 
后退
顶部