Reputation: 43
I wanna use a right2left language in my rich text box but faced a lot of problems with bullets etc. I want to make this
this is my problem can sb help me? thanks
Upvotes: 2
Views: 3890
Reputation: 17176
Just select your richtextbox and set it's RightToLeft
property to Yes
and U will get what U need.
EDITS:
Then, if I understand You correctly, You should parse richtextbox's RTF yourself. Using Microsoft Word I created RTF file with left formatted and right formatted texts, compared their RTF strings and made the following:
Added openFileDialog1 control and two buttons
button1
to open file:
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.RichText);
}
}
and button2
to change richtextbox's RTF string:
private void button2_Click(object sender, EventArgs e)
{
var indexofltrparObject = richTextBox1.Rtf.IndexOf(@"\ltrpar", System.StringComparison.Ordinal);
richTextBox1.Rtf = richTextBox1.Rtf.Insert(indexofltrparObject, @"\qr");
}
So I got before button2
click:
and after:
Is that what You need?
MORE EDITS
To change text align back to LeftToRight just remove "\qr" string You have recently added to richtextbox's RTF string:
private void button3_Click(object sender, EventArgs e)
{
int indexOfQr = richTextBox1.Rtf.IndexOf(@"\qr", System.StringComparison.Ordinal);
if (indexOfQr != -1)
richTextBox1.Rtf = richTextBox1.Rtf.Remove(indexOfQr, @"\qr".Length);
}
Upvotes: 3
Reputation: 1459
If I create an RTB I can change the style to rightToLeft. Just set this option to yes. Hope this is what you want else tell me what you want to do in detail and i may help you ;)
Edit: Maybe you can go this way. Check every line whether the first char is a bullet. If it is true Delete it and appent it to the other side.
Upvotes: 0