Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

c# - How to make Managed Tab Control (MTC) appear right to left

I have used this TabControl to create the following tablayout in a winform application

enter image description here

How do i make the tabs appear right to left?
I mean make it like this image

enter image description here

I also tried to Use RightToLeftLayout property but this tab control doesn't have that property

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It seems that MTC while affected by RightToLeft doesn't draw as expected (In part due to the fact that it statically draws the tabs from left to right and calculates width from the left):

enter image description here

It's easy enough to do in WinForms:

The secret is to apply RightToLeft on your form.

In the properties panel for your form ensure the following are set to Yes and True respectively.

enter image description here

Note that RightToLeft is considered an Ambient property, so child controls should inherit from the parent (so long as the child control doesn't have the property set).

You can read more about that here: https://msdn.microsoft.com/en-us/library/system.windows.forms.control.righttoleft(v=vs.110).aspx

You can read more about RightToLeftLayout here (note that this property does NOT get inherited by children):

https://msdn.microsoft.com/en-us/library/system.windows.forms.form.righttoleftlayout(v=vs.110).aspx

This is the form with RightToLeft set to yes & RightToLeftLayout set to true:

enter image description here

This is the form with RightToLeft set to yes, and RightToLeftLayout set to disabled:

enter image description here

I suggest reading the MSDN articles above if you'd like to have more control over the layout.

Edited: Added additional imagery to show the function of the various properties.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...