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
195
Manipulating columns of a bound grid.
posted

Give these two classes (forgive me for any bad syntax) for the sake of the issue:

public class Pencil
{
   public int Length { get; set; }
   public bool IsMechanical { get; set; }
}

public class PencilCase
{
   private BindingList<Pencil> _pencils = new BindingList<Pencil>();

   public int Color { get;set; }
   public BindingList<Pencil> Pencils {get; set; }
}

Imagine binding a 'BindingList<PencilCase>' to a grid and that BindingList is empty (meaning zero items in it and not null).  I can see that I have a single column in the first band (that column being Color) and another band called Pencils.  In that second band I cannot see the columns that make up Pencil's properties.  Shouldn't I be able to see 'Length' and 'IsMechanical' in that second band?

My problem is that I'm trying to format the way the columns look once after the list had been bound to the grid.  I can format the looks of the band 0 but I can't seem to forumat the columns for band 1 because those columns don't seem to be there.

Thanks for any help :)

Gally

Parents
  • 37774
    posted

    Gally,

    I think that this has to do with the fact that since there are no rows, and especially that there is no child row in the first parent row, the .NET BindingManager is unable to determine the structure of the data, so the grid cannot properly get the columns.  The two workarounds that I can think of are to either add rows to your data, or implement ITypedList on the Pencil class.

    -Matt

Reply Children