bmt22033
bmt22033

Reputation: 7240

Displaying RTL and LTR languages simultaneously in the same control

I'm working on a WinForms application and I have a couple of controls (in particular, a listbox and a datagridview) that will need to display a mix of RTL and LTR data simultaneously. For example, I have a listbox that contains English, Arabic, German and Hebrew strings. Obviously the listbox control has a RightToLeft property and at the moment, I have a button in my UI that lets the user toggle that property between RTL and LTR as they see fit. My customer seems satisfied with this approach but I'm curious how other designers/developers typically deal with this scenario?

Upvotes: 2

Views: 531

Answers (1)

Amir E. Aharoni
Amir E. Aharoni

Reputation: 1318

I don't really know Winforms, but you can probably add Unicode directionality control characters to the actual strings. It's hacky, but it should work.

Here are the relevant characters:

  • RLM (Right-to-left mark) - an invisible right-to-left letter. You can put it after closing parentheses to make sure that it appears on the right end, or between a Hebrew string and a number to make sure that the number comes to the left of the string.
  • LRM (Left-to-right mark) - Like RLM, but for left-to-right.
  • RLE (Right-to-left Embedding) - put it in the beginning of the RTL strings
  • LRE (Left-to-Right Embedding) - put it in the beginning of the LTR strings
  • PDF (Pop directional formatting) - put it in the end of the strings that begin with RLE or LRE. It's similar to the closing tag in HTML: <span dir="rtl">שלום*</span>*

You can copy and paste them from the character map or create strings from Unicode numbers and concatenate them in runtime.

Hope it helps.

Upvotes: 2

Related Questions