Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the color of active TAB in a TabControl, in Delphi

Tags:

How to change the color of active TAB in a TabControl (on FireMonkey) as shown below?

enter image description here

like image 668
wBB Avatar asked Feb 17 '18 01:02

wBB


People also ask

How do I change the color of a tab in access?

Set the tab control to transparent. Behind the tab, place a non-transparent box. Then in the OnChange event of the tab, change the background color of the box behind the tab.

How do I use Tab Control in Delphi?

The user selects a page by clicking the page's tab that appears at the top of the control. To add a new page to a TPageControl object at design time, right-click the TPageControl object and choose New Page. To create a tabbed control that uses only a single body portion (page), use TTabControl instead.


1 Answers

There are 2 ways to make this happen.

1) First option is you can create CustomStyle for TabControl from TStyleBook (Style Designer).

Then you can add whatever you want to use in your custom design (TRectangle is recommmended for many shape and colors).

2) I prefer to use second way for it. Set the TTabControl's TabPosition to None, then add a TGridPanelLayout to where you want to add tabs in your form. After that, set your TGridPanelLayout's column count for your tab count.

Now you need to know that your each tab box should be same. Drop a TRectangle for first column then set Align to Client (All colors and inner components are depends on your choice).

Be sure that your TRectangle components HitTest parameter is true and inner components' HitTest parameter is false.

Also you can handle your tab selections from OnClick event. Set each TRectangle (for tab) a Tag then connect all tabs to same OnClick event. Then you get Sender's Tag and set your TabControl1.ActiveTab from your Tag.

like image 136
Abdullah Ilgaz Avatar answered Sep 21 '22 12:09

Abdullah Ilgaz