DELPHI盒子
!实时搜索: 盒子论坛 | 注册用户 | 修改信息 | 退出
检举帖 | 全文检索 | 关闭广告 | 捐赠
技术论坛
 用户名
 密  码
自动登陆(30天有效)
忘了密码
≡技术区≡
DELPHI技术
lazarus/fpc/Free Pascal
移动应用开发
Web应用开发
数据库专区
报表专区
网络通讯
开源项目
论坛精华贴
≡发布区≡
发布代码
发布控件
文档资料
经典工具
≡事务区≡
网站意见
盒子之家
招聘应聘
信息交换
论坛信息
最新加入: aaaarrrrrrrrrrrr
今日帖子: 62
在线用户: 13
导航: 论坛 -> DELPHI技术 斑竹:liumazi,sephil  
作者:
男 delphi0 (delphi0) ★☆☆☆☆ -
普通会员
2004/7/5 13:04:31
标题:
创建ListView 问题,感谢各位帮忙!!!! 浏览:1393
加入我的收藏
楼主:      Ret:= TListView.Create (Self);
     Ret.Columns.Add;
     Ret.Columns.Add;
     Ret.Columns.Add;
     Ret.Columns.Add;
     For loc_int_I:= 0 to loc_obj_Query.RecordCount - 1
         Do
           Begin
                With Ret.Items.Add
                     Do
                       Begin
                            Caption:= loc_obj_Query.FieldByName (cnt_UserName).Asstring;
                            SubItems.Add (loc_obj_Query.FieldByName (cnt_ReallyName).Asstring);
                            SubItems.Add (loc_obj_Query.FieldByName (cnt_Age).Asstring);
                            SubItems.Add (loc_obj_Query.FieldByName (cnt_PowerMask).Asstring);
                            loc_obj_Query.Next;
                       End;
           End;

为想在一个函数体内返回一组数据(记录).返回TListView 类型

请问在程序里创建的TLIstView 对象. 为什么不能在 ListView 中增加记录. 怎么实现呢?

而在窗体中的TLIstView 就可以.
感谢各位帮忙!!!!
----------------------------------------------
-
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/7/5 13:42:00
1楼: Ret := TListView.Create (Self);
Ret.Parent := Self;
with Ret, loc_obj_Query do
begin
  Columns.Add;
  Columns.Add;
  Columns.Add;
  Columns.Add;

  First;
  while not Eof do
  begin
    with Items.Add do
    begin
      Caption:= FieldByName (cnt_UserName).Asstring;
      SubItems.Add (FieldByName (cnt_ReallyName).Asstring);
      SubItems.Add (FieldByName (cnt_Age).Asstring);
      SubItems.Add (FieldByName (cnt_PowerMask).Asstring);
    end;
    Next;
  end;
end;
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 delphi0 (delphi0) ★☆☆☆☆ -
普通会员
2004/7/5 14:27:09
2楼: sephil ,感谢你的帮助.  还有个问题.

我的程序不是在普通的 pas 文件里,而是一个公用模块, 它没有摆放控件的窗体.

见图(两个图).  请求你的帮助.
此帖子包含附件:
JPEG 图像
大小:58.8K
----------------------------------------------
-
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/7/5 14:38:49
3楼: 作成过程,传个WinControl做参数就行了

procedure CreateListView(APrent: TWinControl);
var 
  Ret: TListView;
begin
  Ret := TListView.Create (AParent);
  Ret.Parent := AParent;
  with Ret, loc_obj_Query do
  begin
....................
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
作者:
男 delphi0 (delphi0) ★☆☆☆☆ -
普通会员
2004/7/5 15:07:23
4楼: sephil, 真是太感谢你了.每当有问题的时候,都是你热心的帮助. 前几天没上去这个论坛, 感觉太没意思.

希望你每天有份好心情.
----------------------------------------------
-
作者:
男 sephil (NAILY Soft) ★☆☆☆☆ -
盒子中级会员
2004/7/5 15:09:29
5楼: 按此在新窗口浏览图片
----------------------------------------------
Copyright 2008 ? NAILY Soft

Click here to redirect to my home
Click here to redirect to my blog
信息
登陆以后才能回复
Copyright © 2CCC.Com 盒子论坛 v3.0.1 版权所有 页面执行78.125毫秒 RSS