我正在处理一些阿拉伯数据,我想从右到左打印
我试过这个
StringFormat format = new StringFormat(StringFormatFlags.DirectionRightToLeft);
e.Graphics.DrawString(dataToPrint, valueFont, System.Drawing.Brushes.Black, 20, 20, format);
但这会使文字仍然从左侧开始,而且会使更糟,所以现在我无法看到所有文字:
但是当我删除format
时,我得到了这个:
我需要完全像第二张图片,但从右到左。
有什么帮助吗?
更新1
这就是我填充dataToPrint
对象
System.Drawing.Font valueFont = new System.Drawing.Font("Arial", 15, System.Drawing.FontStyle.Regular);
string dataToPrint = "";
dataToPrint += "رقم بطاقة التسويق = " + farmID.Text + Environment.NewLine;
dataToPrint += "إسم صاخب المزرعة = " + farmOwner.Text + Environment.NewLine;
dataToPrint += "رقم المزرعة = " + farmNumber.Text + Environment.NewLine;
dataToPrint += "الموبايل = " + farmMobile.Text + Environment.NewLine;
dataToPrint += "الإمارة = " + emaraNameArabic.Text + Environment.NewLine;
dataToPrint += "المنطقة = " + areaNameArabic.Text + Environment.NewLine;
dataToPrint += "الإقليم = " + regionNameArabic.Text + Environment.NewLine;
dataToPrint += "مركز الإستلام = " + receivingCenterName.Text + Environment.NewLine;
dataToPrint += "خلاص = " + khalas.Text + Environment.NewLine;
dataToPrint += "فرض = " + fardh.Text + Environment.NewLine;
dataToPrint += "لولو = " + otherLulu.Text + Environment.NewLine;
dataToPrint += " خنيزي= " + khedrawi.Text + Environment.NewLine;
dataToPrint += "بومعان = " + boumaan.Text + Environment.NewLine;
dataToPrint += "برحي = " + barhi.Text + Environment.NewLine;
dataToPrint += "جش خزمة = " + jeshKharma.Text + Environment.NewLine;
dataToPrint += "رزيز = " + reziz.Text + Environment.NewLine;
dataToPrint += "جبري = " + jabri.Text + Environment.NewLine;
dataToPrint += "عنبرة المدينة = " + anbaretAlMadina.Text + Environment.NewLine;
dataToPrint += " شيشي= " + shishi.Text + Environment.NewLine;
dataToPrint += "دباس = " + dabbas.Text + Environment.NewLine;
dataToPrint += "نبتة سيف = " + nabtetSaif.Text + Environment.NewLine;
dataToPrint += "خضراوي = " + khedrawi.Text + Environment.NewLine;
dataToPrint += "هلالي = " + hilali.Text + Environment.NewLine;
dataToPrint += "مكتومي = " + maktoumy.Text + Environment.NewLine;
dataToPrint += "نميشي = " + namishi.Text + Environment.NewLine;
在@Reyhaneh SH
回答后,我将20更改为400,这是结果,仍然不是从右到左
答案 0 :(得分:1)
您的两个代码都是正确的,但问题是您在X位置使用了20个像素。 X指定左上角的位置。尝试使用:
e.Graphics.DrawString(dataToPrint, valueFont,
System.Drawing.Brushes.Black, 200, 20, format);
您还可以使用任何其他大于20像素的数字。