title: VB Show Listbox text wider than box
body: <p>Does anyone know how to show text that is wider than the listbox, I found some code, it uses a tooltip to show text if its wider but its not working, help please</p>
  
  <p>using VB 2010</p>
  
  <pre><code>Private Sub ListBox2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox2.MouseMove
      Dim ListMousePosition As Point = Me.ListBox2.PointToClient(Me.MousePosition)
      Dim itemIndex As Integer = Me.ListBox2.IndexFromPoint(ListMousePosition)
      If itemIndex &gt; -1 Then
          Dim s As String = Me.ListBox2.Items(itemIndex).ToString()
          Dim g As Graphics = Me.ListBox2.CreateGraphics()
  
          If g.MeasureString(s, Me.ListBox2.Font).Width &gt; Me.ListBox2.ClientRectangle.Width Then
              Me.ToolTip1.SetToolTip(Me.ListBox2, s)
          Else
              Me.ToolTip1.SetToolTip(Me.ListBox2, "")
          End If
           g.Dispose()
      End If
  End Sub
  </code></pre>