I understand the bands concept and I was able to create WinGrid with bands (C#). My Data is hierarchial and it is generated without a DataTable structure. What I'm not able to do is group the headers of bands into a single header row. It would be really helpful if someone can guide me.
In the below example with the data specific to my requirement, Region is the parent and Groups are child. They are related by Region ID which is not displayed. Type and Feature Score belong to band Group. My requirement is to display the headers as shown below, is there any configurable options in WinGrid to achieve the same? Or what is the possible WinGrid that I can create which will resemble this?
Hi Dinesh,
I think it should be possible to achieve this look, or at least something very close to it. But it's really hard to give you any specific advice about how to achieve it without a lot more details about the exact structure of data and exactly what your requirements are.
It looks like this screen shot you have here is from Excel. But this is confusing in a number of ways. For one thing there are no spaces between bands. For another, it looks like your root band here has only one column in it. And each parent row has only a single child row. I'm not sure if any of those things are actually true of your data or your requirements or if they are just the result of the Excel screen shot.
If there is only a single column in the first band, then you might be better off just binding the grid to a flat table of data and then using OutlookGroupBy to group the grid by that field rather than using 2 different bands.
You also mentioned that you are not using a DataTable, which is fine, but the grid cannot function without some kind of data source. It doesn't have to be a DataTable, it could be a DataSet or UltraDataSource, or a BindingList<T>. But there has to be some kind of object providing the data to the grid.
Anyway, if you can provide me some more details about the structure of your data, I'm sure I can help you achieve what you want or something very close to it. For a layout like you have here, you will almost certainly have to set the RowLayoutStyle on the band to GroupLayout and created some groups. You might have to turn off the headers for one band or the other (depending on whether you decide to use multiple bands or not). And you may want to set HeaderPlacement so you can just have a single set of headers at the top of the grid - assuming that's what you want, but that's not really clear to me either.
Hi Mike,
Yes the screenshot was indeed from Excel. I just wanted to show how my grid should look like. I'm adding the Wingrid & Dataset screenshot to this post.
By binding the grid datasource to the dataset, the headers repeat for all bands with default setup. When I set the band header to fixed on top, the band headers add up as 2nd row. But I want them to be grouped into a single header row like in the original post. Hope the screenshots will clear things and thanks for helping me out.
WinGrid Appearance with repeated band headers
DataSet
I whipped up a quick sample that gets pretty close to what you want, I think. I have attached it here for your reference.
It turns out I was wrong - you can't use RowLayoutStyle.GroupLayout here, because the columns in each band don't line up in that style. In other words, the columns in the parent band would not line up with the column headers for the child band, so I don't think that's what you want. Although, maybe I am wrong as I am unsure of your exact requirements.
This sample uses the default RowLayoutStyle (GroupsAndLevels). And then it very simply assigns each column to a group. In this approach, every column has to belong to a group, so the Region and SDIType columns display with both a column header and a group header. It's not exactly what you wanted, but it's as close as I can get without delving into advanced framework extensibility like a CreationFilter. If it's vitally important that you need to remove those extra headers, I can try to point you in the right direction there.
Just in case you decide you don't care about the columms in the first band aligning with the columns in the child band, I implement this using RowLayoutStyle.GroupLayout also. So you can see both approaches and decide which one you like better.