0

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.

Eric
  • 363
  • 2
  • 9
  • 24
  • if `TryCast` cannot perform the cast, it returns `Nothing`. Using the result without testing will cause an NRE when it cant perform the cast. From MSDN: *...TryCast returns Nothing (Visual Basic), so that instead of having to handle a possible exception, you need only test the returned result against Nothing.* – Ňɏssa Pøngjǣrdenlarp May 20 '15 at 18:51
  • I guess this explains why I'm getting a NullReferenceException. Thanks for that. However, I'm still unable to add a grid title to my gridview. – Eric May 20 '15 at 18:56

2 Answers2

0

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
Eric
  • 363
  • 2
  • 9
  • 24
0

Captions must be enabled, they're disabled by default. Add:

  view.OptionsView.ShowViewCaption = true;
Marko Juvančič
  • 5,792
  • 1
  • 25
  • 41