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

旧巷老猫 提交于 2021-01-21 09:08:25

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/48836923/how-to-change-the-color-of-active-tab-in-a-tabcontrol-in-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!