2012-02-14 13 views

答えて

3

このリンクはあなたを助けることがあります。その後、VBで、OwnerDrawするとしてあなたのコンボを設定することを行うにはhttp://www.codeproject.com/Articles/10670/Image-ComboBox-Control

編集、、:それは2008年の言語、そのCまたはCをVBされていない

protected Overrides Sub OnDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs) 

    e.DrawBackground() 
    e.DrawFocusRectangle() 
    Dim item As New ComboBoxIconItem 
    Dim imageSize As New Size 
    imageSize = ListaImg1.ImageSize 
    Dim bounds As New Rectangle 
    bounds = e.Bounds 
    Try 
     item = Me.Items(e.Index) 
     If (item.ImageIndex <> -1) Then 
      Me.ImageList.Draw(e.Graphics, bounds.Left, _ 
       bounds.Top, item.ImageIndex) 
      e.Graphics.DrawString(item.Text, e.Font, _ 
       New SolidBrush(e.ForeColor), bounds.Left + _ 
       imageSize.Width, bounds.Top) 
     Else 
      e.Graphics.DrawString(item.Text, e.Font, _ 
       New SolidBrush(e.ForeColor), bounds.Left, _ 
       bounds.Top) 
     End If 
     Catch ex As Exception 
     If (e.Index <> -1) Then 
      e.Graphics.DrawString(Items(e.Index).ToString(), e.Font, _ 
       New SolidBrush(e.ForeColor), bounds.Left, bounds.Top) 
     Else 
      e.Graphics.DrawString(Text, e.Font, _ 
       New SolidBrush(e.ForeColor), bounds.Left, bounds.Top) 
     End If 
    End Try 
    MyBase.OnDrawItem(e) 
End Sub 
+0

私の事++役に立たなかったですが、迅速な対応に感謝します。 –

+0

それはC#で、そのアイデアを提供し、VBに変換するのは簡単です。 – vulkanino

+1

ownerdrawはプロパティです。あなたのコンボ名をownerdrawとして設定しないでください! – vulkanino

関連する問題