- Namespace MyBiblio.Windows.form
-
- Public Class ComboMaison
-
- Inherits ComboBox
-
- Private m_ImgLst As ImageList
-
- Public Property ImgLst() As ImageList
- Get
- Return m_ImgLst
- End Get
- Set(ByVal Value As ImageList)
- m_ImgLst = Value
- End Set
- End Property
-
- Protected Overrides Sub OnDrawItem(ByVal e As
- System.Windows.Forms.DrawItemEventArgs)
-
- Me.DropDownStyle =
- ComboBoxStyle.DropDownList
-
- MyBase.OnDrawItem(e)
-
- If e.Index = -1 Then
- Exit Sub
- End If
-
- Dim oB As System.Drawing.SolidBrush = New
- System.Drawing.SolidBrush(Me.ForeColor)
-
- If ImgLst.Images.Count <> 0 Then
-
- Dim Img As Image = Me.ImgLst.Images(0)
-
- Dim iX = e.Bounds.Left
- Dim iY = e.Bounds.Top
-
-
- e.Graphics.FillRectangle(SystemBrushes.InactiveCaption,
- e.Bounds)
-
- e.Graphics.DrawImage(Img, CType(iX,
- Single), CType(iY, Single))
-
- e.Graphics.DrawString(Me.Items(0),
- Me.Font, oB, CType(iX, Single) + Img.Width, CType(iY,
- Single))
-
- oB.Dispose()
-
- End If
-
- End Sub
-
- End Class
-
- End Namespace
Namespace MyBiblio.Windows.form
Public Class ComboMaison
Inherits ComboBox
Private m_ImgLst As ImageList
Public Property ImgLst() As ImageList
Get
Return m_ImgLst
End Get
Set(ByVal Value As ImageList)
m_ImgLst = Value
End Set
End Property
Protected Overrides Sub OnDrawItem(ByVal e As
System.Windows.Forms.DrawItemEventArgs)
Me.DropDownStyle =
ComboBoxStyle.DropDownList
MyBase.OnDrawItem(e)
If e.Index = -1 Then
Exit Sub
End If
Dim oB As System.Drawing.SolidBrush = New
System.Drawing.SolidBrush(Me.ForeColor)
If ImgLst.Images.Count <> 0 Then
Dim Img As Image = Me.ImgLst.Images(0)
Dim iX = e.Bounds.Left
Dim iY = e.Bounds.Top
e.Graphics.FillRectangle(SystemBrushes.InactiveCaption,
e.Bounds)
e.Graphics.DrawImage(Img, CType(iX,
Single), CType(iY, Single))
e.Graphics.DrawString(Me.Items(0),
Me.Font, oB, CType(iX, Single) + Img.Width, CType(iY,
Single))
oB.Dispose()
End If
End Sub
End Class
End Namespace