I would like to auto-set the size of a combo column (as is the only one visible in the combo) to be at least equal to the combo actual Width, but not less equal that the tallest string in that column rows.
How to do it?
My code actually:
Private Sub cmb_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles cmbObject.InitializeLayout
Dim combo As UltraCombo = TryCast(sender, UltraCombo) If combo IsNot Nothing AndAlso combo.DisplayLayout.Bands.Count > 0 Then If combo.DisplayLayout.Bands(0).Columns.Count > 1 Then combo.DisplayLayout.Bands(0).Columns(0).Hidden = True combo.DisplayLayout.Bands(0).Columns(1).PerformAutoResize(PerformAutoSizeType.AllRowsInBand) End If End If End Sub
Instead of PerformAutoSize, you can use the CalculateAutoResizeWidth method. This method does essentially the same thing as PerformAutoSize, except that it does not change the Width of the column - it just returns the Width to you.
Then you can set the Width of the column to the Max of the returned width and the width of the control.
I tried
Private Sub cmb_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbObject.Resize Dim combo As UltraCombo = TryCast(sender, UltraCombo) If combo IsNot Nothing AndAlso combo.DisplayLayout.Bands.Count > 0 Then If combo.DisplayLayout.Bands(0).Columns.Count > 1 Then With combo.DisplayLayout.Bands(0).Columns(1) .Width = Math.Max(.CalculateAutoResizeWidth(PerformAutoSizeType.AllRowsInBand, False), combo.Bounds.Width) End With End If End If End Sub
but this does not work after the DataSource of the combo is changed..