Home All Groups Group Topic Archive Search About

combobox view display width question

Author
7 Jul 2006 2:52 PM
BrianDH
Hi
Is there a way to have the view/display width different from the width as it
sits on the form?

Author
7 Jul 2006 4:23 PM
BrianDH
OK, its not the combo control width that i want to set/change, its the width
of the dropdown text value field when someone clicks the combobox. 
Example: the combo is width 50px but there are values that are 100px long,
What I want to do is when the user clicks the combo the drop down part is
wider than the combo control.

Brian

Show quoteHide quote
"BrianDH" wrote:

> Hi
> Is there a way to have the view/display width different from the width as it
> sits on the form?
Author
7 Jul 2006 6:42 PM
BrianDH
Change Dropdown width at runtime
Dim intLength As Integer = CInt(DataSet.Tables(0).Rows.Count)
Dim g As Graphics
g = ComboBox.CreateGraphics()
Dim x As Integer = 0
Dim maxWidth As Integer = 72
Do Until x = intLength
Dim w As Integer =
CInt(g.MeasureString(DataSet.Tables(0).Rows(x).Item(1).ToString,
ComboBox.Font).Width)
If (w > maxWidth) Then
    maxWidth = w
End If
x = x + 1
Loop
g.Dispose()
ComboBox.DropDownWidth = maxWidth


Show quoteHide quote
"BrianDH" wrote:

> Hi
> Is there a way to have the view/display width different from the width as it
> sits on the form?
Author
7 Jul 2006 9:10 PM
Herfried K. Wagner [MVP]
"BrianDH" <Bria***@discussions.microsoft.com> schrieb:
> Is there a way to have the view/display width different from the width as
> it
> sits on the form?

Check out the combobox' 'DropDownWidth' property.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>