I am using a textbox in a .NET 2 winforms app that is setup with a custom AutoCompleteSource. Is there anyway through code that I can increase the width of the list that appears containing the auto complete suggestions?
Ideally I would like to do this without increasing the width of the textbox as I am short for space in the UI.
Not that I know of, but you can auto-size the Textbox so that it is only wide when it needs to be, rather than always as wide as the longest text.
Example from http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3311429&SiteID=1
Public Class Form1
Private WithEvents T As TextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
T = New TextBox
T.SetBounds(20, 20, 100, 30)
T.Font = New Font("Arial", 12, FontStyle.Regular)
T.Multiline = True
T.Text = "Type Here"
T.SelectAll()
Controls.Add(T)
End Sub
Private Sub T_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles T.TextChanged
Dim Width As Integer = TextRenderer.MeasureText(T.Text, T.Font).Width + 10
Dim Height As Integer = TextRenderer.MeasureText(T.Text, T.Font).Height + 10
T.Width = Width
T.Height = Height
End Sub
End Class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With