簡體   English   中英

Tlistview - 有任何組件,如Tlistview但有數據庫訪問?

[英]Tlistview - There is any component like Tlistview but with DB access?

我一直試圖創造一個創造性的東西,以避免dbgrids ,我已經找到了Tlistview (使用alphaskinstslistview的一個),似乎是一個很好的方式!

問題是,我不希望將代碼事件onclick上的每個tlistview定位一個record/dataset根據我所選擇的項目tlistview ..和我同做tlistview item's caption ..並有可能是具有相同名稱的記錄

這是我想避免的代碼之一:

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放在項目標題上..!

有任何想法嗎?

有沒有人知道顯示大量記錄的其他方式,而不僅僅是文本文本和更多文本? 我不知道工具調色板上的所有組件,也許有人可以建議我另一個..

我有時使用從數據庫表加載的列表視圖 - 僅用於少量數據。 我不明白你的意思我不想在每個tlistview上編寫事件onclick來根據我在tlistview上選擇的項目定位記錄/數據集 ,所以我將告訴你我是如何解決這個問題的問題。

基本上,我創建了一個子項,其中包含每個記錄的主鍵。 所有用戶界面代碼都使用兩個列表視圖,最后更新數據庫。 在加載和存儲之間沒有與數據庫的交互(這可能是我避免'onclick'問題的地方)。 每個字段的寬度在Object Inspector中設置; 最終子項的寬度為0(即不顯示)。

加載列表視圖:

 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持有已經連接到給定存款形式的支票。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM