Tlistview-是否有任何类似Tlistview的组件但具有数据库访问权限? [英] Tlistview - There is any component like Tlistview but with DB access?

查看:88
本文介绍了Tlistview-是否有任何类似Tlistview的组件但具有数据库访问权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试做出创造性的事情来避免 dbgrids ,而且我发现了 Tlistview (使用 alphaskins tslistview 中的一个),似乎是一个不错的方法!

I've been trying to make a creative thing to avoid the dbgrids, and i've found the Tlistview (using the one from alphaskins, tslistview), and seems to be a nice way!

问题是,我不想在每个 tlistview onclick $ c>根据我在 tlistview 上选择的项目放置记录/数据集,我用 tlistview项目的标题 ..进行操作,可能会有同名的记录

The problem is, I don't want to code the event onclick on every tlistview to position a record/dataset according to the item I selected on the tlistview .. and I'm doing it with the tlistview item's caption.. and there could be records with the same names

这里是其中之一我要避免的代码:

Here is one of the codes I want to avoid:

with q_find_process do
begin
  close;
  sql.Clear;
  sql.Add('Select * from t_process where process_name like '+quotedstr(streeview1.Selected.Text)+');
  open;
end;

不,我不想将记录的ID放在项目标题上。 !

And no, I don't want to put the ID of the Record on the item caption..!

有什么想法吗?

有人知道其他显示大量记录的方式而不仅仅是文本吗?还有更多文字?我不知道工具选项板上的所有组件,也许有人会建议我其他组件。.

Does anyone know other way of showing a lot of records without being only text text and more text? I don't know all components on the tool palette, maybe someone could suggest me other one..

推荐答案

我有时会使用从数据库表中加载的列表视图-仅用于少量数据。我不明白您的意思是我不想在每个tlistview上的onclick上编写事件代码,以根据我在tlistview上选择的项目定位记录/数据集,所以我要

I have sometimes used listviews which have been loaded from database tables - only for small amounts of data. I don't understand what you mean by I don't want to code the event onclick on every tlistview to position a record/dataset according to the item I selected on the tlistview, so I'm going to show you how I solved this problem.

基本上,我创建了一个子项,其中包含每个记录的主键。所有的用户界面代码都使用两个列表视图,最后,数据库被更新。加载和存储之间没有与数据库的交互(这也许可以避免您的 onclick问题)。每个字段的宽度在对象检查器中设置;最终子项目的宽度为0(即未显示)。

Basically, I create a sub-item which holds the primary key of each record. All the user interface code uses two list views, and at the end, the database is updated. There is no interaction with the database between loading and storing (which might be where I avoid your 'onclick' problem). The widths of each fields are set in the Object Inspector; the final subitem's width is 0 (ie not displayed).

加载列表视图:

 srclist.items.clear;
 with qSrcList do
  begin
   close;
   params[0].asdate:= dt;  // use date of deposit
   open;
   while not eof do
    begin
     ListItem:= srclist.Items.Add;
     ListItem.Caption:= fieldbyname ('kabnum').asstring;
     ListItem.SubItems.Add (fieldbyname ('price').asstring);
     ListItem.SubItems.Add (fieldbyname ('duedate').asstring);
     ListItem.SubItems.Add (fieldbyname ('docket').asstring);
     ListItem.SubItems.Add (fieldbyname ('id').asstring);
     next
    end;
   close
  end;

保存数据:

 with dstlist do
  for index:= 1 to items.count do
   with qInsert do
    begin
     dstlist.itemindex:= index - 1;
     lvitem:= dstlist.selected;
     parambyname ('p1').asinteger:= deposit;
     parambyname ('p2').asinteger:= strtoint (lvitem.SubItems[3]);
     parambyname ('p3').asfloat:= strtofloat (lvitem.SubItems[0]);
     execsql;
    end;

我希望这对您有所帮助。此代码的上下文(不是太重要)在金融应用程序中,用户希望用支票填充银行存款表格。 SrcList保存尚未存入的支票(每个给定日期只有几张),DstList保存已经与给定存入表格关联的支票。

I hope that this helps you. The context of this code (not that it matters too much) is in a financial application where the user wishes to populate a bank deposit form with cheques. SrcList holds the cheques which have yet to be deposited (there will only be a few per given date) and DstList holds the cheques which have already been connected to a given deposit form.

这篇关于Tlistview-是否有任何类似Tlistview的组件但具有数据库访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆