This is unusual problem and need a little explanation.
I have two tables with need to be presented in a parent-child bands.The unusual aspect of these two tables is that they have same set of fields. I won't go into the reasons for this unusual design.
So for example
table1 fields ---> A1 A2 A3 B1 B2 B3 table2 fields ---> A1 A2 A3 B1 B2 B3
In the parent-child bands, I plan to have the columns aligned i.e. no indentation between bands
But I want "A" fields to show only on parent band and the "B" fields aligned. So I want the display to be like this:
A1 A2 A3 B1 B2 B3 <--- parent band shows all fields B1 B2 B3 <--- child bands do not show fields A1, A2 and A3 B1 B2 B3 B1 B2 B3 A1 A2 A3 B1 B2 B3 B1 B2 B3 B1 B2 B3 A1 A2 A3 B1 B2 B3 B1 B2 B3
I think you are going to suggest setting the identation of the child band to start with the first "B" column. I have thought about that approach. There are other alignment and column sizing issue I would run into with that approach.
Ideally I would like to find a way so that for the child bands would present A1, A2 and A3 but with no values (blanks) in those columns. So in short is there a way I can display a column but make the value show blank?
Setting the ForeColor and BackColor is not a reliable way to do this, since the cells may change color if they are selected, activated, or if there is an ApplicationStyle applied. Much better to use the InitializeRow event of the grid and simply set the Hidden property on the cell to true.
Mike,
Mike Saltzman"]Much better to use the InitializeRow event of the grid and simply set the Hidden property on the cell to true.
As I said in my original email, I want the columns to be there for both parent and child band. I just do not want the values to show on the child band for those columns like shown below:
A1 A2 A3 B1 B2 B3 <--- parent band shows all fields B1 B2 B3 <--- child band displays column A1, A2 and A3 (like parent) but values do not show B1 B2 B3 B1 B2 B3 A1 A2 A3 B1 B2 B3 B1 B2 B3 B1 B2 B3 A1 A2 A3 B1 B2 B3 B1 B2 B3
I do not know how to get to that Hidden property for child band only, as suggested in your reply
grid.DisplayLayout.Bands[1] ......?
Thanks!
The InitializeRow event fire one row at a time. So you would examine e.Row.Band and look at either the Index of the band or maybe the Key so see if it's the child band. If so, you loop through e.Row.Cells and set the Hidden property to true on the cells you want to hide.
This would still show the column headers, but I assume you only want one set of column headers at the root level, anyway, so you are probably setting ColHeadersVisible on the child bands to false, anyway.