よりも、リストボックスよりも広くなっているテキストを表示する方法を誰もが知っている、私はそれがより広いが、そのが動作していない、VB表示リストボックスのテキストは、より広いボックス
を助けてください場合は、テキストを表示するツールチップを使用して、いくつかのコードを見つけましたあなたはListBox
にDataTable
をバインドしている場合VB 2010
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 > -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 > 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
はおそらく、あなたが「働いていない」を定義することができることを停止するようにとにかくあります。あなたはデバッグしましたか?そうでない場合は、コードの動作があなたの期待と異なるところを正確に説明してください。 – jmcilhinney
それはsが常に "System.Data.DataRowView"であるので、幅が175で一定であるため、Dim s As String = Me.ListBox2.Items(itemIndex).ToString()はリストボックス内のテキストをピックアップしません。マウスは、私はそれを変更する方法を知らない – JPS