Hi !

I have an owner-drawn listbox on my form. The important properties of the listbox are:
DrawMode = OwnerDrawFixed
HorizontalScrollbar = True

As I see in MSDN, I have to set the HorizontalExtent property to the width of the longest line in the DrawItem event. It is good, if there isn't vertical scrollbar. My DrawItem looks like this:

If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
e.DrawFocusRectangle()
Else
e.DrawBackground()
End If
e.Graphics.DrawString(Me.myListbox.Items(e.Index), e.Font, Brushes.Red, New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
Dim i As Integer
i = e.Graphics.MeasureString(Me.myListbox.Items(e.Index), e.Font).Width
If Me.myListbox.HorizontalExtent < i Then
Me.myListbox.HorizontalExtent = i
End If


BUT if the vertical scrollbar is visible in the listbox, the last few characters of the longest line isn't visible. It's covered by the vertical scrollbar.
I think the solution is:
1. determine whether the vertical scrollbar is visible.
2. increase HorizontalExtent with the width of the vertical scrollbar.

How can I solve this problem.

Thanks
SaNa