dimanche 10 mai 2015

Customize DevExpress GridControl Header Dynamicaly

I have datatable with unknown columns count in my form (data comes from Pivot table in SQL). My data shown by DevExpress GridControl in my Vb.Net Form. I want to assign a BandedGridView object to a grid's main view dynamically according to my columns count with VB code. I can do this for a sevral column like this code. Please help me to do this with loop to all column with code. Sorry for my bad English. Thanks

![enter image description here][1]

'GridControl2 Header Setting
    'Dispose of the old view 
    GridControl2.MainView.Dispose()
    'Create a Banded Grid View 
    Dim bandedView As BandedGridView = New BandedGridView(GridControl2)
    GridControl2.MainView = bandedView
    'Add one band and one column to the view 
    Dim band As GridBand = bandedView.Bands.AddBand("First Year")
    Dim column1 As BandedGridColumn = bandedView.Columns.AddField("9309R")
    Dim column2 As BandedGridColumn = bandedView.Columns.AddField("9309P")
    column1.OwnerBand = band
    column1.Visible = True
    column2.OwnerBand = band
    column2.Visible = True

Aucun commentaire:

Enregistrer un commentaire