FAQ & Knowledge Base

Welcome to our Knowledge Base. Search or browse through the topics below to find answers to your questions.

Categories: ShellBrowser Delphi Components | Show all categories

Scroll item into view

Question / Problem

How can I navigate to an item so that it is scrolled in to visible area of a control?

This doesn't consistently seem to work by typing the first letters of the element.

Answer / Solution

The issue with selecting the element by typing is, that it will only work for elements that have a caption. For performance reasons in the ShellList, loading the caption only occurs when the item is scrolled into view.

However you can force loading the caption sooner by implementing the "OnAddItem" event:

procedure TMainForm.ShellListAddItem(Item: TJamShellListItem;  
var CanAdd: Boolean);
begin  
  Item.Caption := Item.Caption;
end;

In this case the Item.Caption will be assigned when the item is added, so that the incremental search will subsequently work.

Another option to find an item manually, is to use the features that our controls inherited from the TListView control:

var Item := ShellList.FindCaption(0, 'notepad.exe', False, False);
if Assigned(Item) then 
  Item.MakeVisible(False);

If you want to slelect the item, use code like this:

ShellList.SelectedFiles.Add('notepad.exe');