How do I set VirtualGrid column titles in code -behind?

1 Answer 76 Views
VirtualGrid
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Joe asked on 11 Sep 2021, 06:24 PM

I'm trying to use the VirtualGrid to show a collection of read-only  "record" objects in a report.  The problem is that each "record" is just a List<object> whose count and types are not know until runtime.  The column titles are stored separately in a different list of field descriptors.
 

I tried the CellValueNeeded approach (i.e. without using any sort of  DataSource, custom or otherwise), and while my data showed up just fine in the grid, I had no titles on the columns.  There doesn't seem to be any way to set the titles with this approach that I can see.  There is no corresponding ColumnTitleNeeded event, no SetColumnTitle function and no collection of columns I can access.  At least not that I can see  

 So how do I set the column titles in code behind?

(I should add that I also tried the Custom DataSource approach I looked at your VirtualGrid_WPF example in the SDK, but that seems to rely on the fact that each object representing a record ("Club" in the example) has property names and types that areknown at build time.    I could not make it work at all.   )

1 Answer, 1 is accepted

Sort by
0
Accepted
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 12 Sep 2021, 04:11 PM
I am embarrassed to admit that I now see the event I needed was there, called HeaderValueNeeded.  My Intellisense was only showing me CellValueNeeded and no other events.   I needed to clear out the cached Intellisense data before everything started showing up again.

Sorry for wasting anyone's time with a RTFM question.  I would delete this if I could
Martin Ivanov
Telerik team
commented on 14 Sep 2021, 08:09 AM

Thank you for sharing your solution. I believe that this answer is going to be useful for anyone that hit the same scenario.
Tags
VirtualGrid
Asked by
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Joe
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or