您的位置:程序门 -> delphi -> 网络通信/分布式开发



如何将listview中的内容从服务器端发送给客户端,并显示在客户端的listview中?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何将listview中的内容从服务器端发送给客户端,并显示在客户端的listview中?
发表于:2008-01-10 10:46:37 楼主
我现在在服务器端有一个listview,里面的内容是客户端想要得到的内容.现在不知道如何通过serversocket将listview的内容sendtext给客户端,并且客户端在接收到之后显示在客户端的listview中?
发表于:2008-01-10 14:46:311楼 得分:0
服务端请一个程序,当客户端请求时把里面的内容打包后发给客户端,客户端收到后再解包再显示。
发表于:2008-01-10 17:47:372楼 得分:0
服务端监听客户端的请求,接受到客户端的socket请求时就把listview里的内容按一定格式发给客户端,客户端接受到后解析出内容再显示
发表于:2008-01-10 19:40:183楼 得分:0
如果listview当中的内容是可存储并还原的,就可以。否则无法实现。

items[0]:caption[,subitems[0][,subitems[1][,...[,subitems[m]]]]][,data][,checked][,imageindex]
items[1]:caption[,subitems[0][,subitems[1][,...[,subitems[m]]]]][,data]][,checked][,imageindex]
...
items[n]:caption[,subitems[0][,subitems[1][,...[,subitems[m]]]]][,data]][,checked][,imageindex]

也就是一个二维表格。这就是最基本的listview数据,只是这个二维表格是不规则的。subitems可有可无,也可能是不确定的m项。还有一个可有可无的,可以存任何类型的是data。除此之外还有checked属性,以及imageindex(如此有,可能需要将整个imagelist的图片都进行传输)等。

发表于:2008-01-10 23:33:064楼 得分:0
可采用序列化控件存储成流,然后把流发送到客户端,客户端控件就从服务端接收的流还原。
以下是网络上转摘的代码。

delphi(pascal) code
procedure tform1.savecomponent; var stream: tfilestream; begin stream := tfilestream.create('c:\temp\mycomponent.dat', fmcreate); try stream.writecomponent(mycomponent);//此处可以修改一下,即把stream发送给客户端。 finally stream.free; end; end; example of loading a component from the file: 以下是从文件读取流,修改成从socket接收即可。 procedure tform1.f; var stream: tfilestream; mycomponent: tcomponent; begin stream := tfilestream.create('c:\temp\mycomponent.dat', fmopenread); try stream.readcomponent(mycomponent); finally stream.free; end; end;


快速检索

最新资讯
热门点击