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
180
UseFixedHeaders align columns
posted

As you can see from the picture, after setting the properties:

e.Layout.UseFixedHeaders = True
e.Layout.StationaryMargins = StationaryMargins.Header

To lock the first column of the grid and the headers, the columns are no longer aligned with the respective header.
Below attached the code I use in InitializeLayout:

    Protected Sub Dati_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles Dati.InitializeLayout
        Dim DS_GRIGLIA As New DataSet
        Dim Colonna As Infragistics.WebUI.UltraWebGrid.UltraGridColumn
        Dim APPO_ROW As DataRow()
        Dim M As Integer
        Dim F As Integer = 1
        Dim colHead As ColumnHeader
        Dim i As Integer
        Dim ch As New ColumnHeader(True)
        Dim CONTA_COLONNE As Int16
        Try
            DS_GRIGLIA = Session("Dati")
            'IMPOSTAZIONI GENERALI DELLA GRIGLIA
            CONTA_COLONNE = DS_GRIGLIA.Tables("LIVELLO_COLONNE").Rows.Count
            e.Layout.Bands(0).AllowAdd = Infragistics.WebUI.UltraWebGrid.AllowAddNew.No
            e.Layout.Bands(0).AllowDelete = Infragistics.WebUI.UltraWebGrid.AllowDelete.No
            e.Layout.Bands(0).AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
            e.Layout.Bands(0).CellClickAction = CellClickAction.Edit
            e.Layout.Bands(0).AllowSorting = AllowSorting.No
            e.Layout.Bands(0).AllowColumnMoving = AllowColumnMoving.None
            e.Layout.AddNewRowDefault.Visible = AddNewRowVisible.No
            e.Layout.UseFixedHeaders = True 'SERVE PER BLOCCARE LE COLONNE
            e.Layout.StationaryMargins = StationaryMargins.Header 'SERVE PER BLOCCARE GLI HEADER DELLA GRIGLIA
            '**********************************************************
            'FORMATTAZIONE COLONNE*************************************
            '**********************************************************
            'CICLO DI TUTTE LE COLONNE IN GRIGLIA
            For Each Colonna In e.Layout.Bands(0).Columns
                Select Case Colonna.Key
                    Case "FK_ID_LIV0", "FK_ID_LIV1", "FK_ID_LIV2", "FK_ID_LIV3"
                        Colonna.Hidden = True
                    Case "TOTALE_TC"
                        Colonna.Header.Caption = "TOTALE"
                        ''TOTALE = True
                        Colonna.AllowUpdate = AllowUpdate.No
                        Colonna.Header.Style.HorizontalAlign = HorizontalAlign.Center
                        Colonna.CellStyle.HorizontalAlign = HorizontalAlign.Right
                        Colonna.CellStyle.Wrap = False
                        Colonna.CellStyle.Padding.Right = 2
                        Colonna.CellStyle.Padding.Left = 2
                    Case "DESCRIZIONE_LIV3"
                        Colonna.Width = 300
                        Colonna.Header.Fixed = True
                        Colonna.AllowUpdate = AllowUpdate.No
                        Colonna.Header.Caption = "DESCRIZIONE"
                        Colonna.CellStyle.Wrap = True
                        Colonna.CellStyle.Padding.Right = 2
                        Colonna.CellStyle.Padding.Left = 2
                        Colonna.Header.Style.HorizontalAlign = HorizontalAlign.Center
                        Colonna.CellStyle.HorizontalAlign = HorizontalAlign.Left
                    Case Else
                        Select Case Mid(Colonna.Key, 1, 3)
                            Case "TC_"
                                Colonna.IsBound = True
                                Colonna.AllowUpdate = AllowUpdate.Yes
                                Colonna.Header.Style.HorizontalAlign = HorizontalAlign.Center
                                Colonna.CellStyle.HorizontalAlign = HorizontalAlign.Right
                                Colonna.CellStyle.Wrap = False
                                Colonna.CellStyle.Padding.Right = 2
                                Colonna.CellStyle.Padding.Left = 2
                                APPO_ROW = DS_GRIGLIA.Tables("LIVELLO_COLONNE").Select("TC = " & Mid(Colonna.Key, 4, 2))
                                Colonna.Header.Caption = APPO_ROW(0)("DESCRIZIONE").ToString
                                Colonna.CellStyle.HorizontalAlign = HorizontalAlign.Right
                        End Select
                End Select
            Next
            '**********************************************************
            'FORMATTAZIONE TITOLI**************************************
            '**********************************************************
            'GLI HEADERS DELLE COLONNE VENGONO SPOSTATI SOTTO
            For i = 0 To e.Layout.Bands(0).HeaderLayout.Count - 1
                colHead = e.Layout.Bands(0).HeaderLayout(i)
                colHead.RowLayoutColumnInfo.OriginY = 1
            Next
            'NEW TITOLO DESCRIZIONE VUOTO
            ch.Caption = ""
            ch.RowLayoutColumnInfo.OriginX = 0
            ch.RowLayoutColumnInfo.OriginY = 0
            e.Layout.Bands(0).HeaderLayout.Add(ch)
            'CREAZIONE DEI TITOLI SULLE COLONNE
            For M = 0 To DS_GRIGLIA.Tables("LIVELLO_TITOLI").Rows.Count - 1
                ch = New ColumnHeader(True)
                ch.Style.Wrap = False
                'CAPTION DELLA COLONNA
                ch.Caption = DS_GRIGLIA.Tables("LIVELLO_TITOLI").Rows(M)("DESCRIZIONE").ToString
                ch.Style.HorizontalAlign = HorizontalAlign.Center
                'ORIGINE X DELLA COLONNA
                ch.RowLayoutColumnInfo.OriginX = F
                'ORIGINE Y DELLA COLONNA
                ch.RowLayoutColumnInfo.OriginY = 0
                If M = DS_GRIGLIA.Tables("LIVELLO_TITOLI").Rows.Count - 1 And Session("TIPO_SOMMA") = "C" Then
                    'SPAN SULLA X DELLE COLONNE
                    ch.RowLayoutColumnInfo.SpanX = DS_GRIGLIA.Tables("LIVELLO_TITOLI").Rows(M)("NUM_COLONNE") + 1
                Else
                    'SPAN SULLA X DELLE COLONNE
                    ch.RowLayoutColumnInfo.SpanX = DS_GRIGLIA.Tables("LIVELLO_TITOLI").Rows(M)("NUM_COLONNE")
                End If
                'ADD TITOLO
                'ch.Fixed = False
                e.Layout.Bands(0).HeaderLayout.Add(ch)
                'INCREMENTO
                F = F + DS_GRIGLIA.Tables("LIVELLO_TITOLI").Rows(M)("NUM_COLONNE")
            Next
        Catch ex As Exception

        Finally

        End Try
    End Sub