please,
how do i draw image in listbox_DrawItem event by the left side
i already read throught this code, buts its not helping me
Dim targetsize As New Size(16, 16)
Dim img As Image = Nothing
img = My.Resources._error
e.Graphics.DrawImage(img, targetsize)
e.Graphics.DrawString(lsbLog.Items(e.Index).ToString(), _
e.Font, mybrush, e.Bounds, StringFormat.GenericDefault)
this is my current code
EDIT
i added your code with some other code, and i get a garbled text
this is part of the code in the DrawItem event
'//Here it draws the border depeding on it's state (the listbox item)
e.Graphics.DrawRectangle(myPen, e.Bounds.X + 16, e.Bounds.Y, _
e.Bounds.Width - 16, e.Bounds.Height)
Using b As New SolidBrush(e.ForeColor)
e.Graphics.DrawString(lsbLog.GetItemText(lsbLog.Items(e.Index)), e.Font, b, e.Bounds)
End Using
e.Graphics.DrawImage(img, New Rectangle(e.Bounds.Width - 15, e.Bounds.Y, 12, 12))
'// Draw the current item text based on the current
'// Font and the custom brush settings.
e.Graphics.DrawString(lsbLog.Items(e.Index).ToString(), e.Font, mybrush, _
New Rectangle(e.Bounds.X - 20, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), _
StringFormat.GenericDefault)
This is the code in the MeasureItem event
Private Sub lsbLog_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles lsbLog.MeasureItem
Dim g As Graphics = e.Graphics
'We will get the size of the string which we are about to draw,
'so that we could set the ItemHeight and ItemWidth property
Dim size As SizeF = g.MeasureString(lsbLog.Items.Item(e.Index).ToString, Me.Font, _
lsbLog.Width - (5 + SystemInformation.VerticalScrollBarWidth))
e.ItemHeight = CInt(size.Height) + 5
e.ItemWidth = CInt(size.Width) + 5
End Sub
I get a garbeled text and image

Two points come to my attention:
Did you set the DrawMode to
DrawMode.OwnerDrawFixedorDrawMode.OwnerDrawVariable, as stated in the documentation?You seem to be drawing the text directly over the image. Why do you use
e.Boundsin DrawString instead of a rectangle that starts a little bit to the right? E.g. something like:BTW, you shouldn’t forget to call
DrawBackgroundandDrawFocusRectangeas seen in the example in the documentation.