線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3296
推到 Plurk!
推到 Facebook!

listview要搜尋SubItems裡面的值

答題得分者是:Fishman
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-11-21 18:02:54 IP:61.221.xxx.xxx 未訂閱
各位大大: 請問有關listview要搜尋SubItems裡面的值使用何種方式!
------
======================
昏睡~
不昏睡~
不由昏睡~
ghyghost
一般會員


發表:3
回覆:8
積分:2
註冊:2003-03-16

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-21 18:08:56 IP:218.27.xxx.xxx 未訂閱
form1.ListView1.FindCaption ??
solnone
中階會員


發表:2
回覆:97
積分:69
註冊:2003-05-06

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-21 19:24:41 IP:61.222.xxx.xxx 未訂閱
找某一個 SubItem if ListView1.Items.Item[0].SubItems.IndexOf('line1') > -1 then ; 找 SubItems if Pos('a', ListView1.Items.Item[0].SubItems.Text) > 0 then ;
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-24 09:52:00 IP:61.221.xxx.xxx 未訂閱
引言: ghyghost form1.ListView1.FindCaption ??
回ghyghost這個好像只找上面item確沒找到SubItem <>< face="Verdana, Arial, Helvetica">引言: solnone 找某一個 SubItem if ListView1.Items.Item[0].SubItems.IndexOf('line1') > -1 then ; 找 SubItems if Pos('a', ListView1.Items.Item[0].SubItems.Text) > 0 then ; 回solnone那要搜尋整個ListView1就要寫回圈了是嗎? 再請問既然有FindCaption可以找item那有沒有找SubItem的函式或偷雞方式呢?
------
======================
昏睡~
不昏睡~
不由昏睡~
aquarius
資深會員


發表:3
回覆:347
積分:330
註冊:2003-05-21

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-11-24 10:41:01 IP:211.23.xxx.xxx 未訂閱
請參考 TListView 的 FindData 及 OnDataFind ...Aquarius
------
水瓶男的blog: http://791909.blogspot.com
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-11-24 10:51:39 IP:210.65.xxx.xxx 未訂閱
Hi:    
procedure TForm1.Button1Click(Sender: TObject);
var
    Index : Integer;
begin
    if (ListView1.Items.Item[0].SubItems AS TStringList).Find(Edit1.Text,Index) then
        ShowMessage(IntToStr(Index));
end;
小弟才疏學淺,若有謬誤請不吝指教 ---------------------- 新手上路,請多多指教 ----------------------
------
Fishman
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-11-24 11:13:49 IP:61.221.xxx.xxx 未訂閱
引言: aquarius 請參考 TListView 的 FindData 及 OnDataFind
回aquarius
引言: procedure TForm1.ListViewDataFind(Sender: TObject; Find: TItemFind; const FindString: String; const FindPosition: TPoint; FindData: Pointer; StartIndex: Integer; Direction: TSearchDirection; Wrap: Boolean; var Index: Integer); //OnDataFind gets called in response to calls to FindCaption, FindData, //GetNearestItem, etc. It also gets called for each keystroke sent to the //ListView (for incremental searching) var I: Integer; Found: Boolean; begin I := StartIndex; if (Find = ifExactString) or (Find = ifPartialString) then begin repeat if (I = FIDList.Count-1) then if Wrap then I := 0 else Exit; Found := Pos(UpperCase(FindString), UpperCase(ShellItem(I)^.DisplayName)) = 1; Inc(I); until Found or (I = StartIndex); if Found then Index := I-1; end; end;
還是只有找到item而非subitem <>< face="Verdana, Arial, Helvetica">引言: Fishman procedure TForm1.Button1Click(Sender: TObject); var Index : Integer; begin if (ListView1.Items.Item[0].SubItems AS TStringList).Find(Edit1.Text,Index) then ShowMessage(IntToStr(Index)); end; 回Fishman這個小弟測不出來,他都沒有ShowMessage to me!! 冒昧問一下!!非常光碟....共人是嗯是裡台 >
------
======================
昏睡~
不昏睡~
不由昏睡~
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-11-24 11:58:46 IP:210.65.xxx.xxx 未訂閱
Hi:    小程式,供你參考    
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls;    type
  TForm1 = class(TForm)
    Button1: TButton;
    ListView1: TListView;
    ComboBox1: TComboBox;
    procedure Button1Click(Sender: TObject);
    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
      Selected: Boolean);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  Form1 : TForm1;
  Index : Integer;    implementation    {$R *.dfm}    procedure TForm1.Button1Click(Sender: TObject);
var
    Id : Integer;
begin
    if (ListView1.Items.Item[Index].SubItems AS TStringList).Find(ComboBox1.Text,Id) then
        ShowMessage(IntToStr(Id))
    else
        ShowMessage('No Match Data Found !!');
end;    procedure TForm1.ListView1SelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
VAR
    I : Integer;
begin
    IF Selected THEN
        BEGIN
            Index := Item.Index;
            ComboBox1.Items.Clear;
            FOR I := 0 TO Item.SubItems.Count - 1 DO
                BEGIN
                    ComboBox1.Items.Add(Item.SubItems.Strings[I]);
                END;
            ComboBox1.ItemIndex := 0;
        END;
end;    procedure TForm1.FormCreate(Sender: TObject);
begin
    ListView1.OnSelectItem(ListView1,ListView1.Items.Item[0],True);
end;    end.
-------------------------------- 小弟才疏學淺,若有謬誤請不吝指教 --------------------------------
------
Fishman
Fishman
尊榮會員


發表:120
回覆:1949
積分:2163
註冊:2006-10-28

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-11-24 12:41:26 IP:210.65.xxx.xxx 未訂閱
Hi:    
procedure TForm1.Button1Click(Sender: TObject);
var
    I : Integer;
begin
    FOR I := 0 TO ListView1.Items.Item[Index].SubItems.Count - 1 DO
        BEGIN
            IF POS(ComboBox1.Text,ListView1.Items.Item[Index].SubItems.Strings[I]) > 0 THEN
                BEGIN
                    ShowMessage(ListView1.Items.Item[Index].SubItems.Strings[I]);
                    Exit;
                END;
        END;
    ShowMessage('No Match Data Found !!');
end;
-------------------------------- 小弟才疏學淺,若有謬誤請不吝指教 --------------------------------
------
Fishman
ko
資深會員


發表:28
回覆:785
積分:444
註冊:2002-08-14

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-11-24 14:52:19 IP:61.221.xxx.xxx 未訂閱
Fishman (漁夫兄): 此法可行,漁夫果然有見地,不過測試迴圈在750已上都還可以,感謝
------
======================
昏睡~
不昏睡~
不由昏睡~
系統時間:2024-03-29 18:40:33
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!