1 (edited by AD1408 2017-06-29 19:21:13)

Topic: Disable tab page

Is it possible to disable a specific tab page on a PageControl?
If so, what's the script please?


This hides a tab page:

frmInvoice.tpSaleInv.TabVisible := False;

However this doesn't disable it:

frmInvoice.tpSaleInv.TabEnabled := False;
Adam
God... please help me become the person my dog thinks I am.

Re: Disable tab page

This should work.


Form1.TabSheet1.Enabled := False;

3 (edited by derek 2017-06-29 23:38:39)

Re: Disable tab page

Hi Adam, EHW,
EHW is right - form1.tabsheet1.enabled := false works.  I realise in my earlier post I was testing for an incorrect condition (idiot!).
Just to clarify (please see attached)
1.  form1.tabsheet1.enabled := false will disable all fields on a tabsheet but leave everything (fields and tabsheet frame) visible
2.  form1.tabsheet1.tabvisible := false will make both fields and tabsheet frame invisible
3.  form1.tabsheet1.visible := false will make the fields invisible but keep the tabsheet frame visible
Apologies for any confusion.
Derek.

Post's attachments

Attachment icon adam disable tab.zip 336.22 kb, 365 downloads since 2017-06-30 

Re: Disable tab page

Hi Guys,


Thank you very much.................


What I was trying to do is disabling the click of tab itself in a multi tabs situation. User sees all available tabs but cannot click other than predefined tab with something like

Form2.pagecontrol1.ActivePageIndex := 1;
Form2.TabSheet0.Enabled  := False;
Form2.TabSheet2.Enabled  := False;
Form2.TabSheet3.Enabled  := False;

Perhaps it's not possible...


Derek, I added radio button simulation for the checkboxes so that only one can be selected.

procedure Form1_CheckBox1_OnClick (Sender: string);
begin
  if form1.checkbox1.checked = true then form1.tabsheet1.enabled := false else form1.tabsheet1.enabled := true;
     Form1.CheckBox2.Checked := False;
     Form1.CheckBox3.Checked := False;
end;

procedure Form1_CheckBox2_OnClick (Sender: string);
begin
  if form1.checkbox2.checked = true then form1.tabsheet1.tabvisible := false else form1.tabsheet1.tabvisible := true;
     Form1.CheckBox1.Checked := False;
     Form1.CheckBox3.Checked := False;
end;

procedure Form1_CheckBox3_OnClick (Sender: string);
begin
  if form1.checkbox3.checked = true then form1.tabsheet1.visible := false else form1.tabsheet1.visible := true;
     Form1.CheckBox2.Checked := False;
     Form1.CheckBox1.Checked := False;
end;


How can I use multiple statements with and in one line something like below which doesn't work:

procedure Form1_CheckBox1_OnClick (Sender: string);
begin
  if form1.checkbox1.checked = true then form1.tabsheet1.enabled := false else form1.tabsheet1.enabled := true;
     //Form1.CheckBox2.Checked := False;
     //Form1.CheckBox3.Checked := False;
     (Form1.CheckBox2.Checked) and (Form1.CheckBox3.Checked) := False;
end

Is it possible to use more than one and on same line?

Adam
God... please help me become the person my dog thinks I am.