Quote
"Deelg" <m...@logera.com> wrote in message news:3c06bf1c$1_1@dnews...
> to find a ListView item via its Caption theres the FindCaption(...)
method.
> I wonder what function to be used to search in other SubItems in the
> TListView ??????? I need to find an item based on text in the 6e subitem.
There is no such function, sorry. You'll have to do the search yourself
manually by iterating through the items in a loop until you find the one
you're looking for.
For example, here's a variation of the FindData() method, for searching a
SubItem instead:
TListItem* __fastcall FindSubItem(TListView *ListView, int StartIndex, int
SubItemIndex, AnsiString Value, bool Partial, bool Inclusive, bool Wrap)
{
TListItem *Item = NULL;
if(Inclusive)
StartIndex--;
int count = ListView->Items->Count;
for(int i = (StartIndex + 1); i < count; i++)
{
Item = ListView->Items->Item[i];
if(Item != NULL)
{
AnsiString subvalue = Item->SubItems->Strings[SubItemIndex];
if( (Partial && (subvalue.Pos(Value) == 1)) || (!Partial &&
(subvalue == Value)) )
return Item;
}
}
if(Wrap)
{
if(Inclusive)
StartIndex++;
for(int i = 0; i < StartIndex; i++)
{
Item = ListView->Items->Item[i];
if(Item != NULL)
{
AnsiString subvalue = Item->SubItems->Strings[SubItemIndex];
if( (Partial && (subvalue.Pos(Value) == 1)) || (!Partial &&
(subvalue == Value)) )
return Item;
}
}
}
return NULL;
Then you should be able to call it like this:
TListItem *FoundItem = FindSubItem((TListView *)Sender, 0, 5,
"01110027TA", false, true, false);
Quote
> Antoher question is about highlighting an TListView Item after a search. I
> use the follwing code, this selects the found item but this does NOT
> higlight it.
> How to realise that ?
Better to just set the TListItem's Selected property directly, no need to
use Sender:
FoundItem->MakeVisible(false);
FoundItem->Selected = true;
Gambit