RightToLeft 레이아웃은 아랍어 및 히브리어 문화권 용이며 오른쪽에서 왼쪽으로 텍스트를 씁니다. 또한 텍스트가 렌더링되는 방법에 영향을 미치며 부작용을 발견하게됩니다. 원하는 방식으로 소유자 그리기를 사용해야합니다. 프로젝트에 새 클래스를 추가하고 아래 표시된 코드를 붙여 넣습니다. 엮다. 새 컨트롤을 도구 상자의 위쪽에서 폼으로 끌어다 놓습니다.
using System;
using System.Drawing;
using System.Windows.Forms;
class ReverseListBox : ListBox {
public ReverseListBox() {
this.DrawMode = DrawMode.OwnerDrawFixed;
}
protected override void OnDrawItem(DrawItemEventArgs e) {
e.DrawBackground();
if (e.Index >= 0 && e.Index < this.Items.Count) {
var selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
var back = selected ? SystemColors.Highlight : this.BackColor;
var fore = selected ? SystemColors.HighlightText : this.ForeColor;
var txt = this.Items[e.Index].ToString();
TextRenderer.DrawText(e.Graphics, txt, this.Font, e.Bounds, fore, back, TextFormatFlags.Right | TextFormatFlags.SingleLine);
}
e.DrawFocusRectangle();
}
}
대단히 고마워! 훌륭한 작품 (적어도 IronPython 모듈로). –