0

In my application, I have a TListBox with a Search box. Within each item is a TTreeView for data display (Expand/collapse feature needed). Why do I do this instead of just using a TTreeView without the TListbox, well because I want the search functionality that I can use with a TListBox and a TTreeview doesn't scroll as nicely. Anyway, so my problem is that Lets say I have each ListBoxItem.size := 80.. It looks great, works great etc. etc. etc... But then When I want to expand the TreeViewItem within each ListBoxItem to view it's child TreeViewItems, then I can not see all the data and I would need to re-size the TListBoxItem.

How can re-size a ListBoxItem when a TTreeItem is expanded?

Using Delphi Xe5 to develop an iOS application.

tshepang
  • 12,111
  • 21
  • 91
  • 136
ThisGuy
  • 1,405
  • 1
  • 24
  • 51

1 Answers1

0

For any looking for an answer, here is what I came up with... Keep in mind, the TreeView and all of its nodes are created dynamically and placed withing dynamically created listboxitems. All of the .HitTest properties of all the treeView & TreeviewItem components are set to 'False', and I've placed an image over the expand button on each tree view to perform my own action below :

procedure TMain_Form.Image1Click(Sender: TObject);
var
Item    : TListBoxItem;
view    : TTreeView;
tree1,
tree2   : TTreeViewItem;
height  : extended;
i       :integer;
begin
Item := TListBoxItem.Create(nil);
Item := TImage(Sender).Parent as TListBoxItem;
view := Item.Children.Items[1] as TTreeview;
tree1 := View.Items[0];
i := 0; height :=  0;
while i <> Tree1.Count do begin
  tree2 := tree1.Items[i];
  height := height + 40;
  i := i + 1;
end;
if item.Height = 40 then begin
  tree1.ExpandAll;
  item.Height := Item.height + height;
  view.height := Item.height;
end else begin
  View.CollapseAll;
  Item.Height := 40;
end;

No need for the the 'while' statement, I realize that. I had just had it in there from messing around before hand was admittedly to lazy to change it.

ThisGuy
  • 1,405
  • 1
  • 24
  • 51