Page 1 of 1

how to fix indent in TTreeView component

PostPosted: September 17th, 2005, 6:01 am
by ssfftt
I have this procedure to retrieve data from catagory and product tables in my interbase firebird1.5 database, and display them into a TreeView1 component.

how come all the products are shown with the same indent as categories? i tried to add '.....' before every product to increase the indent, it looked soo ugly.

btw, i tried the example code in delphi help, very samilar code with mine, but it didnt generate this problem.

can any one help me with this plz?


Code: Select all
procedure TfrmProduct.btnShowAllProductsClick(Sender: TObject);
begin
       TreeView1.Items.Clear;
       Category.IBQueryCategory.First;
       while not Category.IBQueryCategory.Eof do
       begin
           TreeView1.Items.Add(nil, Category.IBQueryCategoryNAME.AsString);
           Product.IBQueryProduct.Open;
           Product.IBQueryProduct.First;
           while not Product.IBQueryProduct.Eof do
           begin
               if Product.IBQueryProductCATEGORYID.AsString = Category.IBQueryCategoryCATEGORYID.AsString then
               begin
                   TreeView1.Items.AddChild(nil, Product.IBQueryProductNAME.AsString);
               end;
           Product.IBQueryProduct.Next;
           end;
           Category.IBQueryCategory.Next;
       end;

end;

PostPosted: September 17th, 2005, 2:35 pm
by Kambiz
TTreeView follows a hierarchial structure. It meens you should add products as a child of their appropriate category.

Alternatively you can use TListView and use Indent property of TListItem to indent products.

Cheers