Jump to content
PeterPanettone

TTabSheet - Set color and remove margin?

Recommended Posts

In a Delphi 10.4 VCL Application, I have a TPageControl container with a TTabSheet page (with TabVisible = False) and a TPanel on that TabSheet:

 

image.png.5f3d8faf85ef75c5be4d763ac9844bfb.png

 

Although the Panel has Align = alClient, the Panel does not completely fill the TabSheet area: The TabSheet creates a MARGIN AREA around the Panel which I cannot get rid of. (The margin area is from the TabSheet and not from the Form, as the Form.Color is set to Fuchsia).

 

So I thought I could make the margin invisible by setting the TabSheet color to the same color as the Panel. BUT TTabSheet does not have a color property!

 

I have attached the very simple project, so you can play around with it yourself:

 

TabSheetColor.zip

 

Question: Is there a way to set the color of the full area of the TabSheet or to remove that margin from the TabSheet?

Share this post


Link to post

It would be far simpler to remove the page control and tabsheet and have the panel placed directly on the form.

Share this post


Link to post
5 minutes ago, David Heffernan said:

It would be far simpler to remove the page control and tabsheet and have the panel placed directly on the form.

If you have several panels then the handling becomes expensive.

 

Anything about the TPageControl/TTabsheet?

Share this post


Link to post
39 minutes ago, PeterPanettone said:

Anything about the TPageControl/TTabsheet? 

You may try to set PageControl.Style to tsFlatButtons (but I don't know if the result is what you want).

Share this post


Link to post

Is that what you want ?

procedure TForm1.FormCreate(Sender: TObject);
type
  TControlHack = type TControl;
begin
  TControlHack(pgc1).Color := clWindow;
end;

 

Share this post


Link to post
1 hour ago, PeterPanettone said:

If you have several panels then the handling becomes expensive.

It's not at all difficult. Put them in a collection and hide all of them apart from the active one.

 

Has the benefit of doing exactly what you want. 

Share this post


Link to post
4 hours ago, David Heffernan said:

It's not at all difficult. Put them in a collection and hide all of them apart from the active one.

Good idea. Could you provide some example code?

Share this post


Link to post

Seems that a TCardPanel is better suited for your needs.

Quote

Use the TCardPanel to manage a collection of cards. Each card is a container for other controls and only one card is active/visible at a time.

 

  • Like 1
  • Thanks 2

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×