Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
610
Conditionally hide column for child rows
posted

We have two bands. Depending upon a condition in each row of Band(0), we want to either show/hide a column on its Band(1) child rows.

Instead of hiding the column, simply setting the header text for the column to String.Empty would also work (we don't have to worry about the cells since they'll be empty anyways).

Is there any way to achieve this effect? The typical ways I'd solve this problem unfortunately hide the column across the whole grid, which is not what we want.

  • 469350
    Offline posted

    Hi,

    Is the column you want to hide the last column? You can hide the column using a CreationFilter or DrawFilter, but this would not remove the space - there would still be a gap where the column would have been. So if it's the last column, this would work better.

    If not, then it's probably not a good approach to take, because the borders would look odd and you'd have a big gap in your grid.

    If you just want to blank out the column header, then you could set the column.Header.Caption to a single space character so it appears blank.

    Another option might be to restructure your data source so that there are two child bands which are siblings to each other - one with the column and one without it. Then you just make sure that each parent row only has child rows in one band or the other, but not both. The down side of this approach is that you have to change your data structure, and also that it would not be easy to switch the column on and off based on a value in the parent row.

    Another option you might consider is using UltraWinTree instead of UltraWinGrid. The up side is that you can assign a ColumnSet to a nodes collection dynamically. So this would allow you to hide or remove the column under the parent node with no problem. The down side is that you would have to change your grid to a tree, and also that the tree lacks certain grid functionality that you might need like summaries, filtering, printing, and exporting.