Search code examples
c#winformstabcontroltabpage

Fixing mirror displayed tabPage in c#


I have used this Metro.dll to create the following TabControl
I want tabPages displayed as right to left on the top,
But when i do it the text on the tab page displayed as mirrored as shown in the following Image

enter image description here

How to fix this problem?


Solution

  • After some investigation it looks like the source code for this library of Windows Forms controls is at GitHub. Download it and build it on your machine.

    Look into the MetroTabControl class which seems to be extended tab control of the basic Microsoft's tab control. Particularly, look for the TextRenderer.DrawText(graphics, tabPage.Text, EffectiveFont, tabRect, EffectiveForeColor, EffectiveBackColor, TextAlign.AsTextFormatFlags() | TextFormatFlags.EndEllipsis); method.

    The important argument here is TextFormatFlags and it needs to be set to TextFormatFlags.RightToLeft | TextFormatFlags.Right when the tab control is mirrored or RightToLeft and RightToLeftLayout are set to Yes and True.

    As it turns out to be oversight in the source code of the library, you can modify it according to your needs and eventually submit a pull request to the project owner.