how to fix indent in TTreeView component

Please discuss general Delphi programming topics here.

how to fix indent in TTreeView component

Postby ssfftt » September 17th, 2005, 6:01 am

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;
ssfftt
Active Member
Active Member
 
Posts: 9
Joined: September 6th, 2005, 5:02 pm

Postby Kambiz » September 17th, 2005, 2:35 pm

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
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 10 guests

cron