我有自定義的「組合框」和我使用的是阿拉伯語,我需要它從右到左,在默認的「組合框」我可以把它從性質改變,但在這個定製的「組合框」其沒有改變,所以我怎樣才能修改這個類,使它從右到左?組合框項目左
這是我使用的是什麼:
Class AdvancedComboBox
Inherits ComboBox
Public Shadows Property DrawMode() As System.Windows.Forms.DrawMode
Get
Return m_DrawMode
End Get
Set
m_DrawMode = Value
End Set
End Property
Private Shadows m_DrawMode As System.Windows.Forms.DrawMode
Public Property HighlightColor() As Color
Get
Return m_HighlightColor
End Get
Set
m_HighlightColor = Value
End Set
End Property
Private m_HighlightColor As Color
Public Sub New()
MyBase.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
Me.HighlightColor = Color.Orange
AddHandler Me.DrawItem, New DrawItemEventHandler(AddressOf AdvancedComboBox_DrawItem)
End Sub
Private Sub AdvancedComboBox_DrawItem(sender As Object, e As DrawItemEventArgs)
If e.Index < 0 Then
Return
End If
Dim combo As ComboBox = TryCast(sender, ComboBox)
If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
e.Graphics.FillRectangle(New SolidBrush(HighlightColor), e.Bounds)
Else
e.Graphics.FillRectangle(New SolidBrush(combo.BackColor), e.Bounds)
End If
e.Graphics.DrawString(combo.Items(e.Index).ToString(), e.Font, New SolidBrush(combo.ForeColor), New Point(e.Bounds.X, e.Bounds.Y))
e.DrawFocusRectangle()
End Sub
End Class
謝謝你的完美,但如果你能幫助我,我將是偉大的充分,這個問題有點事在默認'combobox'其還組織(文本對齊方式),當在阿拉伯語和英語的用戶類型顯示爲用戶類型,並保存在數據庫中,現在在定製'combobox'如果我有3個字,如:Arabic1數據庫中的英語阿拉伯語2在自定義'combobox'中顯示如下:Arabic2 English Arabic1。 順便說一句,我在一行顯示2個值: 'ComboBox2.Items.Add(String.Format(「{0} |({1})」,p_id,p_name))' –
@Rabeeaqabaha我道歉,但我正在努力處理您在評論中提出的問題。如果你想要三個項目,那麼它只是'String.Format(「{0} {1} {2}」,p_id,p_name,p_other)',但我懷疑這不是你面臨的問題。 – LarsTech
我的問題是文本結構不正確,例如: 可以說用戶在數據庫中添加了3個單詞阿拉伯語和1個英語單詞,如[word1(Arabic1)word2(English)word3(Arabic2)] ', '組合框'顯示它就像這樣'[word3(Arabic2)word2(English)word1(Arabic1)]' –