Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1187
Auto size first column to fit grid width
posted

How can I setup a view only grid that has several fixed width columns and only have the first column autosize to fit the width of the grid?  I've tried several things but nothing works.

 An example of what I've tried, I want the name column to autosize to fit the grid width and have all the other columns fixed width:

Private Sub UltraGrid1_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
        Dim c As UltraGridColumn

        e.Layout.AutoFitStyle = AutoFitStyle.ResizeAllColumns

        For Each c In e.Layout.Bands(0).Columns
            c.CellActivation = Activation.NoEdit
            c.AllowRowFiltering = DefaultableBoolean.False

            Select Case c.Key.ToLower
                Case "name"
                    c.Header.Caption = "Campaign"

                Case "type_name"
                    c.Header.Caption = "Type"
                    c.Width = 80
                    c.LockedWidth = True

                Case "date_lastrun"
                    c.Header.Caption = "Last Run"
                    c.Width = 80
                    c.LockedWidth = True

                Case "date_nextrun"
                    c.Header.Caption = "Next Run"
                    c.Width = 80
                    c.LockedWidth = True

                Case "service_codes_type_name"
                    c.Header.Caption = "Codes Type"
                    c.Width = 120
                    c.LockedWidth = True

                Case Else
                    c.Hidden = True

            End Select
        Next

    End Sub

Parents
  • 17259
    Offline posted

    Try to write this after the For Each for the column you want to resize:

    column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand, true)

Reply Children
No Data