Programmatically Set Devexpress AdvBandedGridView

Posted On // Leave a Comment
'Set Grid Column
Sub __SetGridColumn()
        Dim bandTransaksi = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandSuratJalan = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandDistribusi = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandDebitNote = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandKendaraan = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandValid = New DevExpress.XtraGrid.Views.BandedGrid.GridBand, _
            bandBatal = New DevExpress.XtraGrid.Views.BandedGrid.GridBand

        With gridPenjualanAdvBandedView
            .Bands.Clear()
            .Bands.AddRange(New DevExpress.XtraGrid.Views.BandedGrid.GridBand() _
                            {bandTransaksi, bandSuratJalan, bandDistribusi, bandDebitNote, bandKendaraan, bandValid, bandBatal})
            .GridControl = gridPenjualan
            .OptionsView.ColumnAutoWidth = False
            .Columns(0).DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
            .Columns(0).DisplayFormat.FormatString = "dd-MMM-yyyy"
            .Columns(0).Caption = "Tanggal"
            .Columns(0).Width = 75

            With .OptionsView
                .ShowChildrenInGroupPanel = True
                .ShowColumnHeaders = True
                .ShowAutoFilterRow = True
            End With

            .GroupFooterShowMode = Views.Grid.GroupFooterShowMode.VisibleAlways

            'bandTransaksi.Fixed = Columns.FixedStyle.Left
            With .Columns(4)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Tanggal"
                .Width = 75
            End With
            With .Columns(5)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Nomor"
                .Width = 75
            End With
            With .Columns(6)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Tanggal"
                .Width = 75
            End With
            With .Columns(7)
                .Caption = "Nomor"
                .Width = 75
            End With
            With .Columns(8)
                .Caption = "Tanggal"
                .Width = 75
            End With
            With .Columns(9)

                .Caption = "Nomor"
                .Width = 75
            End With
            With .Columns(10)
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
                .DisplayFormat.FormatString = "dd-MMM-yyyy"
                .Caption = "Tgl. J. Tempo"
                .Width = 75
            End With

            .Columns(11).Visible = False

            With .Columns(17)
                .Caption = "Gross"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(18)
                .Caption = "Discount"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(19)
                .Caption = "DPP"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(20)
                .Caption = "PPN"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(21)
                .Caption = "Netto"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(22)
                .Caption = "Gross"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(23)
                .Caption = "Discount"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(24)
                .Caption = "DPP"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(25)
                .Caption = "PPN"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
            With .Columns(26)
                .Caption = "Netto"
                .DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
                .DisplayFormat.FormatString = "n0"
            End With
        End With

        With bandTransaksi
            .Caption = "Pembelian"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(0))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(1))
            .Width = 200
        End With

        With bandSuratJalan
            .Caption = "Surat Jalan"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(2))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(3))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(4))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(5))
            .Width = 500
        End With

        With bandDistribusi
            .Caption = "Distribusi"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(6))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(7))
        End With

        With bandDebitNote
            .Caption = "Debit Note"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(8))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(9))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(10))
        End With

        With bandKendaraan
            .Caption = "Kendaraan"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(11))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(12))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(13))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(14))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(15))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(16))
        End With

        With bandValid
            .Caption = "Valid"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(17))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(18))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(19))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(20))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(21))
            .Width = 350
        End With

        With bandBatal
            .Caption = "Batal"
            .Columns.Add(gridPenjualanAdvBandedView.Columns(22))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(23))
            .Columns.Add(gridPenjualanAdvBandedView.Columns(24))
            .Width = 350
        End With
        gridPenjualanAdvBandedView.BestFitColumns()
    End Sub

0 komentar: