[Visual Basic] Protected Overrides Sub OnDrawItem( _
ByVal e As DrawItemEventArgs _
)
[Visual Basic] Protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
If e.Index = -1 Then Return
' Draw only the combo edit box
If (e.State And DrawItemState.ComboBoxEdit) <> DrawItemState.ComboBoxEdit Then Return
Dim ComboBoxSelection As TreeNodeEx
Try
ComboBoxSelection = CType(Me.Items(e.Index), TreeNodeEx)
e.DrawFocusRectangle()
e.DrawBackground()
Dim TextLeft As Integer = e.Bounds.Left
If Not Me.TreeView.ImageList Is Nothing Then
Dim ImageIndex As Integer = ComboBoxSelection.TreeNode.SelectedImageIndex
If ImageIndex < 0 Then ImageIndex = Me.TreeView.SelectedImageIndex
If ImageIndex >= 0 Then
Dim IconRectangle As Rectangle
If Me.TreeView.ImageList.ImageSize.Height > Me.ItemHeight Then
IconRectangle = New Rectangle(e.Bounds.Left + 2, e.Bounds.Top, Me.ItemHeight, Me.ItemHeight)
Else
IconRectangle = New Rectangle(New Point(e.Bounds.Left + 2, e.Bounds.Top), Me.TreeView.ImageList.ImageSize)
End If
Me.TreeView.ImageList.Draw(e.Graphics, IconRectangle.Left, IconRectangle.Top, IconRectangle.Width, IconRectangle.Height, ImageIndex)
TextLeft = TextLeft + IconRectangle.Width + 2
IconRectangle = Nothing
End If
End If
e.Graphics.DrawString(ComboBoxSelection.TreeNode.Text, Me.Font, New SolidBrush(e.ForeColor), TextLeft, e.Bounds.Top + 2)
Catch ex As Exception
Throw ex
Finally
ComboBoxSelection = Nothing
MyBase.OnDrawItem(e)
End Try
End Sub
Plattformen: Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition