Search code examples
vb.netgridviewdevexpress-windows-ui

Unable to add grid title to gridview using DevExpress vb.net


I've tried the following code found on the DevExpress site but I get a NullReferenceException at the view.Bands.Clear()

Dim view As BandedGridView = TryCast(gridControl1.MainView, BandedGridView)
view.Bands.Clear()

'Create the bands layout.  
 Dim bandProdInf As GridBand = view.Bands.Add()
 bandProdInf.Caption = "Notification Details - Drilling"

This would be the look of the gridview that I would like: https://www.devexpress.com/Support/Center/Attachment/GetAttachmentFile/e5cb046f-fb25-46a4-9ae8-25ba612daa01

"Notification Details - Drilling" would appear as the title of the gridview.


Solution

  • The support team from devexpress provided the following right answer:

    The GridView offers a built-in mechanism for showing a title via the ViewCaption property. Additionally you will want to set the GridView's OptionsView.ShowViewCaption property to True.

    So you would do the following:

    gridview1.ViewCaption = "Grid view title"
    gridview1.OptionsView.ShowViewCaption = True