I have a UserControl that has a TableLayoutPanel on it. That panel has only one row and two columns - a NumericUpDown control in the first, and a ComboBox in the second.
Whenever the items in the combobox get updated the combobox is resized according to the following routine:
The column the ComboBox is in is also set to auto-size. The NumericUpDown column is set for a percentage and both controls have their anchor set to "Left, Right".
The above describe UserControl works fine - except when itself is placed within a TableLayoutPanel, at which point the size gets reduced to 0,0 and I am unable to resize it.
Any ideas on what is causing this or how to get around it?
Thanks.
Whenever the items in the combobox get updated the combobox is resized according to the following routine:
Code:
Private Sub ResizeCombo()
Dim g As Graphics = cboUnits.CreateGraphics
Dim maxWidth As Integer
For Each obj As Object In cboUnits.Items
Dim s As String = obj.ToString
Dim intWidth As Integer
intWidth = CInt(g.MeasureString(s, cboUnits.Font).Width)
maxWidth = Math.Max(maxWidth, intWidth)
Next
cboUnits.Width = maxWidth + SystemInformation.VerticalScrollBarWidth
Me.Invalidate()
End Sub
The above describe UserControl works fine - except when itself is placed within a TableLayoutPanel, at which point the size gets reduced to 0,0 and I am unable to resize it.
Any ideas on what is causing this or how to get around it?
Thanks.