BiDiMode適用於從右向左書寫的語言,因此不適用於您的需求。
我看不出用TComboBoxEx做到這一點的方法,但你可以很容易地用TComboBox來做到這一點。
添加一個TComboBox並使其風格csOwnerDrawFixed。我在下面的代碼中假定了TImageList(你必須已經擁有)和TComboBox的基本名稱。你將需要修改它爲你自己的名字。添加一個類似於下面的OnDrawItem事件。 (你可能想把它稍微提高一點)。
procedure TForm1.ComboBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
iImageWidth, iTextWidth, iMargin : integer;
iText : string;
iCanvas : TCanvas;
begin
// draw image at right and text right justify
// assume image index = Item for now.
iCanvas := ComboBox1.Canvas;
// need to check state; Just ignore for now.
iImageWidth := ImageList1.Width;
iMargin := 4; // pixels - can calculate instead
iText := ComboBox1.Items[ Index ];
iTextWidth := iCanvas.TextWidth(iText);
ImageList1.Draw(iCanvas, Rect.Right - iImageWidth - iMargin, Rect.Top, Index);
iCanvas.TextOut(Rect.Right - 2 * iMargin - iTextWidth - iImageWidth, Rect.Top, iText);
end;
我已經測試過它,它工作正常
更新
這裏是操作我對它的形象與正好所示的代碼
來源
2015-09-03 10:02:42
Dsm
我沒能重現XE5的bug 。該項目以下列方式顯示 - 下拉按鈕 - 最左側 - 左側的圖像和文本無空格。請提供MCVE。 –
@ asd-tm嗨。我編輯了我的帖子。請檢查一下。 – smartiz
嗨。現在我明白你到底想要什麼。我刪除了我的答案。希望,這個零答案得分會吸引社區對你的問題的關注。 –