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
4028
Hiding columns in child bands conditionally
posted

I have a multi-band UltraGrid in my winforms project. In one of the child bands, there is a column which I dont want to always see. Whether or not I want to see it is dependant on a field in the parent row.

So now I'm setting the column hidden/visible in the BeforeRowExpanded event of the ultragrid, as below:

        void ultraGrid_BeforeRowExpanded(object sender, CancelableRowEventArgs e)

        {

            Item item = e.Row.ListObject as Item;

            if (item.SingleColour)

            {

                e.Row.ChildBands[constColourBand].Band.Columns["UnitCost"].Hidden = true;

                e.Row.ChildBands[constColourBand].Band.Columns["UnitCost"].ExcludeFromColumnChooser = ExcludeFromColumnChooser.True;

            }

            else

            {

                e.Row.ChildBands[constColourBand].Band.Columns["UnitCost"].Hidden = false;

                e.Row.ChildBands[constColourBand].Band.Columns["UnitCost"].ExcludeFromColumnChooser = ExcludeFromColumnChooser.False;

 

            }

        }

 The problem is, this code changes the column hidden property for *all* bands - that is, the child bands (of this type) within other parent rows. Obviously this is not what I want - I only want to set this property for the child band being expanded, not the child bands for other rows.

How can I acheive what I want here? How do I prevent it from hiding the columns in the child bands of other rows?

Thanks. 

 

Parents
  • 469350
    Verified Answer
    Offline posted

     Hi,

        You cannot. A Column is either hidden or it's not. There's no way to hide it only in some islands of data and not in others.

        You might consider using WinTree instead of WinGrid. The WinTree allows you to assign a ColumnSet to a collection of Nodes. Thus you could have two different ColumnSets that are the same except for the existance (or lack thereof) or a particular column and assign that ColumnSet to the nodes collections as you want. 

        Of course, the tree has other limitations. For example, it does not support Filtering or Summaries like the grid does.  

Reply Children