Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this happen with ToolStripMenuItems?

Tags:

c#

.net

When adding a ToolStripMenuItem to a form and setting RightToLeft to true and having a quote at the end of the text does it place the quote at the front of the Text?

ToolStripMenuItem1.Text = "Name \"Text\"";
ToolStripMenuItem1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;

Displays as; "Name "Text

Edit: This also happens with single quotes.

like image 872
ManicResin Avatar asked Oct 10 '22 04:10

ManicResin


1 Answers

By setting RightToLeft to Yes, you are asking the Windows text rendering engine to apply the text layout rules used in languages that use a right-to-left order. Arabic and Hebrew. Those rules are pretty subtle, especially because English phrases in those languages are not uncommon. It is not going to render "txeT emaN" as it normally does with Arabic or Hebrew glyphs, that doesn't make sense to anybody. It needs to identify sentences or phrases and reverse those. Quotes are special, they delineate a phrase.

Long story short, you are ab-using a feature to get alignment that was really meant to do something far more involved. Don't use it for that.

like image 132
Hans Passant Avatar answered Oct 14 '22 04:10

Hans Passant