Board index » delphi » Question about the Treeview

Question about the Treeview

Hi,

I want to use a treeview to select specific page.

I have three options:

- 1) Accounting
- 2) Pen settins
- 3) Job parameters

I want to use a pagecontrol to change my active page?

How can i select a item and then change my pagecontrol?

Regards,

Ben van Erp

 

Re:Question about the Treeview


Ben,

Try something like this

procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
PageControl1.ActivePage.PageIndex:= Integer(TreeView1.Selected.Index);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
PageControl1.ActivePage.PageIndex:= 0;// or whatever page you want to
open on.
end;

Quote
>Hi,

>I want to use a treeview to select specific page.

>I have three options:

>- 1) Accounting
>- 2) Pen settins
>- 3) Job parameters

>I want to use a pagecontrol to change my active page?

>How can i select a item and then change my pagecontrol?

>Regards,

>Ben van Erp

Re:Question about the Treeview


OnChange event for the Treeview, then, pagecontrol.activepage := somepage

try reading the help for more info.

--
Martijn Tonies

<- remove some characters from my email adress to reply ->
m.ton...@somecharacters.upscene.demon.nl
http://www.upscene.demon.nl

B van Erp heeft geschreven in bericht <7m067d$rk...@news.worldonline.nl>...

Quote
>Hi,

>I want to use a treeview to select specific page.

>I have three options:

>- 1) Accounting
>- 2) Pen settins
>- 3) Job parameters

>I want to use a pagecontrol to change my active page?

>How can i select a item and then change my pagecontrol?

>Regards,

>Ben van Erp

Re:Question about the Treeview


Ben,

Here is a better way to do it. The last one didn't work properly.

procedure TForm1.FormActivate(Sender: TObject);
begin
PageControl1.ActivePage:=TabSheet1;
end;

procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
case Integer(TreeView1.Selected.Index) of
0:PageControl1.ActivePage:= TabSheet1;
1:PageControl1.ActivePage:= TabSheet2;
2:PageControl1.ActivePage:= TabSheet3;
3:PageControl1.ActivePage:= TabSheet4;
end;
end;

procedure TForm1.PageControl1Change(Sender: TObject);
begin
TreeView1.Selected :=
TreeView1.Items[PageControl1.ActivePage.PageIndex];
end;

The snag is you have to add to the CASE statement each time you put a
new TabSheet in. You could fiddle around with a For loop to do it
automatically or try other properties.

Hope this gets you going,

Ian Millward

Quote
>Hi,

>I want to use a treeview to select specific page.

>I have three options:

>- 1) Accounting
>- 2) Pen settins
>- 3) Job parameters

>I want to use a pagecontrol to change my active page?

>How can i select a item and then change my pagecontrol?

>Regards,

>Ben van Erp

Other Threads